[Mesa-dev] [Bug 42688] attribute can't be used when it used fixed function vertex

2015-06-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=42688

Shuang He  changed:

   What|Removed |Added

 CC||christophe.prig...@intel.co
   ||m

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 56836] xdemo/texture_from_pixmap failed to create drawable on swrast

2015-06-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=56836

Shuang He  changed:

   What|Removed |Added

 CC||christophe.prig...@intel.co
   ||m

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 62202] Mesa demo dest window of wincopy flickers while toggle f/b buffer on software render

2015-06-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=62202

Shuang He  changed:

   What|Removed |Added

 CC||christophe.prig...@intel.co
   ||m

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 90797] [ALL bisected] Mesa change cause performance case manhattan fail.

2015-06-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=90797

Shuang He  changed:

   What|Removed |Added

 CC||christophe.prig...@intel.co
   ||m

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 54805] gl_ClipVertex support horribly broken with software TNL

2015-06-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=54805

Shuang He  changed:

   What|Removed |Added

 CC||christophe.prig...@intel.co
   ||m

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 79629] [Dri3 bisected] piglit glx_GLX_ARB_create_context_current_with_no_framebuffer fail

2015-06-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=79629

Shuang He  changed:

   What|Removed |Added

 CC||christophe.prig...@intel.co
   ||m

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 13978] [Mesa core] glGetIntegerv(GL_DRAW_BUFFER0) returns wrong buffer enum

2015-06-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=13978

Shuang He  changed:

   What|Removed |Added

 CC||christophe.prig...@intel.co
   ||m

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 29418] ARB_vp: large offsets when using relative addressing

2015-06-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=29418

Shuang He  changed:

   What|Removed |Added

 CC||christophe.prig...@intel.co
   ||m

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] winsys/radeon: Unmap GPU VM address range when destroying BO

2015-06-16 Thread Michel Dänzer
From: Michel Dänzer 

But only when doing so is safe according to the
RADEON_INFO_VA_UNMAP_WORKING kernel query.

This avoids GPU VM address range conflicts when the BO has other
references than the GEM handle being closed, e.g. when the BO is shared.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90537
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90873

Cc: "10.5 10.6" 
Signed-off-by: Michel Dänzer 
---
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 29 +++
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c |  4 
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.h |  1 +
 3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index fe98870..a2532cf 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -305,14 +305,35 @@ static void radeon_bo_destroy(struct pb_buffer *_buf)
 if (bo->ptr)
 os_munmap(bo->ptr, bo->base.size);
 
+if (mgr->va) {
+int r = 0;
+
+if (bo->rws->va_unmap_working) {
+struct drm_radeon_gem_va va;
+
+va.handle = bo->handle;
+va.vm_id = 0;
+va.operation = RADEON_VA_UNMAP;
+va.flags = RADEON_VM_PAGE_READABLE |
+   RADEON_VM_PAGE_WRITEABLE |
+   RADEON_VM_PAGE_SNOOPED;
+va.offset = bo->va;
+r = drmCommandWriteRead(bo->rws->fd, DRM_RADEON_GEM_VA, &va, 
sizeof(va));
+if (r && va.operation == RADEON_VA_RESULT_ERROR) {
+fprintf(stderr, "radeon: Failed to deallocate virtual address 
for buffer:\n");
+fprintf(stderr, "radeon:size  : %d bytes\n", 
bo->base.size);
+fprintf(stderr, "radeon:va: 0x%016llx\n", 
(unsigned long long)bo->va);
+}
+   }
+
+if (r == 0)
+   radeon_bomgr_free_va(mgr, bo->va, bo->base.size);
+}
+
 /* Close object. */
 args.handle = bo->handle;
 drmIoctl(bo->rws->fd, DRM_IOCTL_GEM_CLOSE, &args);
 
-if (mgr->va) {
-radeon_bomgr_free_va(mgr, bo->va, bo->base.size);
-}
-
 pipe_mutex_destroy(bo->map_mutex);
 
 if (bo->initial_domain & RADEON_DOMAIN_VRAM)
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index ba8d143..d457f8a 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -57,6 +57,8 @@
 #define RADEON_INFO_READ_REG   0x24
 #endif
 
+#define RADEON_INFO_VA_UNMAP_WORKING   0x25
+
 static struct util_hash_table *fd_tab = NULL;
 pipe_static_mutex(fd_tab_mutex);
 
@@ -399,6 +401,8 @@ static boolean do_winsys_init(struct radeon_drm_winsys *ws)
 if (!radeon_get_drm_value(ws->fd, RADEON_INFO_IB_VM_MAX_SIZE, NULL,
   &ib_vm_max_size))
 ws->info.r600_virtual_address = FALSE;
+radeon_get_drm_value(ws->fd, RADEON_INFO_VA_UNMAP_WORKING, NULL,
+ &ws->va_unmap_working);
 }
if (ws->gen == DRV_R600 && !debug_get_bool_option("RADEON_VA", FALSE))
ws->info.r600_virtual_address = FALSE;
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h 
b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
index 166b6b9..99c8b8a 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
@@ -74,6 +74,7 @@ struct radeon_drm_winsys {
 enum radeon_generation gen;
 struct radeon_info info;
 uint32_t va_start;
+uint32_t va_unmap_working;
 uint32_t accel_working2;
 
 struct pb_manager *kman;
-- 
2.1.4

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


Re: [Mesa-dev] [PATCH] winsys/radeon: Unmap GPU VM address range when destroying BO

2015-06-16 Thread Christian König

On 16.06.2015 10:28, Michel Dänzer wrote:

From: Michel Dänzer 

But only when doing so is safe according to the
RADEON_INFO_VA_UNMAP_WORKING kernel query.

This avoids GPU VM address range conflicts when the BO has other
references than the GEM handle being closed, e.g. when the BO is shared.


That actually doesn't really helps, it just masks the problem for now. 
The other GEM handle could still require the address space just unmapped 
and freed.


What we would need to really clean that up is to make the VM mappings 
per GEM handle like you suggested or allow multiple mappings per BO like 
we did it for Amdgpu.


Another alternative is to teach radeon_bomgr_free_va that a certain 
address range could be allocated to more than one handle.


Regards,
Christian.



Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90537
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90873

Cc: "10.5 10.6" 
Signed-off-by: Michel Dänzer 
---
  src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 29 +++
  src/gallium/winsys/radeon/drm/radeon_drm_winsys.c |  4 
  src/gallium/winsys/radeon/drm/radeon_drm_winsys.h |  1 +
  3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index fe98870..a2532cf 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -305,14 +305,35 @@ static void radeon_bo_destroy(struct pb_buffer *_buf)
  if (bo->ptr)
  os_munmap(bo->ptr, bo->base.size);
  
+if (mgr->va) {

+int r = 0;
+
+if (bo->rws->va_unmap_working) {
+struct drm_radeon_gem_va va;
+
+va.handle = bo->handle;
+va.vm_id = 0;
+va.operation = RADEON_VA_UNMAP;
+va.flags = RADEON_VM_PAGE_READABLE |
+   RADEON_VM_PAGE_WRITEABLE |
+   RADEON_VM_PAGE_SNOOPED;
+va.offset = bo->va;
+r = drmCommandWriteRead(bo->rws->fd, DRM_RADEON_GEM_VA, &va, 
sizeof(va));
+if (r && va.operation == RADEON_VA_RESULT_ERROR) {
+fprintf(stderr, "radeon: Failed to deallocate virtual address for 
buffer:\n");
+fprintf(stderr, "radeon:size  : %d bytes\n", 
bo->base.size);
+fprintf(stderr, "radeon:va: 0x%016llx\n", (unsigned 
long long)bo->va);
+}
+   }
+
+if (r == 0)
+   radeon_bomgr_free_va(mgr, bo->va, bo->base.size);
+}
+
  /* Close object. */
  args.handle = bo->handle;
  drmIoctl(bo->rws->fd, DRM_IOCTL_GEM_CLOSE, &args);
  
-if (mgr->va) {

-radeon_bomgr_free_va(mgr, bo->va, bo->base.size);
-}
-
  pipe_mutex_destroy(bo->map_mutex);
  
  if (bo->initial_domain & RADEON_DOMAIN_VRAM)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index ba8d143..d457f8a 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -57,6 +57,8 @@
  #define RADEON_INFO_READ_REG  0x24
  #endif
  
+#define RADEON_INFO_VA_UNMAP_WORKING	0x25

+
  static struct util_hash_table *fd_tab = NULL;
  pipe_static_mutex(fd_tab_mutex);
  
@@ -399,6 +401,8 @@ static boolean do_winsys_init(struct radeon_drm_winsys *ws)

  if (!radeon_get_drm_value(ws->fd, RADEON_INFO_IB_VM_MAX_SIZE, 
NULL,
&ib_vm_max_size))
  ws->info.r600_virtual_address = FALSE;
+radeon_get_drm_value(ws->fd, RADEON_INFO_VA_UNMAP_WORKING, NULL,
+ &ws->va_unmap_working);
  }
if (ws->gen == DRV_R600 && !debug_get_bool_option("RADEON_VA", FALSE))
ws->info.r600_virtual_address = FALSE;
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h 
b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
index 166b6b9..99c8b8a 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
@@ -74,6 +74,7 @@ struct radeon_drm_winsys {
  enum radeon_generation gen;
  struct radeon_info info;
  uint32_t va_start;
+uint32_t va_unmap_working;
  uint32_t accel_working2;
  
  struct pb_manager *kman;


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


Re: [Mesa-dev] [PATCH] winsys/radeon: Unmap GPU VM address range when destroying BO

2015-06-16 Thread Michel Dänzer
On 16.06.2015 17:34, Christian König wrote:
> On 16.06.2015 10:28, Michel Dänzer wrote:
>> From: Michel Dänzer 
>>
>> But only when doing so is safe according to the
>> RADEON_INFO_VA_UNMAP_WORKING kernel query.
>>
>> This avoids GPU VM address range conflicts when the BO has other
>> references than the GEM handle being closed, e.g. when the BO is shared.
> 
> That actually doesn't really helps, it just masks the problem for now.
> The other GEM handle could still require the address space just unmapped
> and freed.

In theory, yes. In practice, I think only the Mesa driver actually uses
GPUVM addresses, not the other parts involved in these issues (the Xorg
radeon driver or the Android gralloc). The Mesa driver is careful not to
have several representations of the same BO.

Or do you expect this might cause trouble with GL<->VDPAU or GL<->CL
interop?


> What we would need to really clean that up is to make the VM mappings
> per GEM handle like you suggested or allow multiple mappings per BO like
> we did it for Amdgpu.

What kind of time-frame / effort do you think it would take to get that?


> Another alternative is to teach radeon_bomgr_free_va that a certain
> address range could be allocated to more than one handle.

What exactly do you have in mind for that? I don't think the winsys has
several representations of the same BO in the cases fixed by this patch,
and I'm not sure how it could account for external references.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] glsl: Fail linkage when UBO exceeds GL_MAX_UNIFORM_BLOCK_SIZE.

2015-06-16 Thread Jose Fonseca
It's not totally clear whether other Mesa drivers can safely cope with
over-sized UBOs, but at least for llvmpipe receiving a UBO larger than
its limit causes problems, as it won't fit into its internal display
lists.

This fixes piglit "arb_uniform_buffer_object-maxuniformblocksize
fsexceed" without regressions for llvmpipe.

NVIDIA driver also fails to link the shader from
"arb_uniform_buffer_object-maxuniformblocksize fsexceed".

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65525

PS: I don't recommend cherry-picking this for Mesa stable, as some app
might inadvertently been relying on UBOs larger than
GL_MAX_UNIFORM_BLOCK_SIZE to work on other drivers, so even if this
commit is universally accepted it's probably best to let it mature in
master for a while.
---
 src/glsl/linker.cpp | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 9978380..4a726d4 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -2355,6 +2355,13 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
unsigned total_uniform_blocks = 0;
 
for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
+  if (prog->UniformBlocks[i].UniformBufferSize > 
ctx->Const.MaxUniformBlockSize) {
+ linker_error(prog, "Uniform block %s too big (%d/%d)\n",
+  prog->UniformBlocks[i].Name,
+  prog->UniformBlocks[i].UniformBufferSize,
+  ctx->Const.MaxUniformBlockSize);
+  }
+
   for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) {
 if (prog->UniformBlockStageIndex[j][i] != -1) {
blocks[j]++;
-- 
2.1.0

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


[Mesa-dev] [Bug 65525] [llvmpipe] lp_scene.h:210:lp_scene_alloc: Assertion `size <= (64 * 1024)' failed.

2015-06-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=65525

José Fonseca  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|mesa-dev@lists.freedesktop. |jfons...@vmware.com
   |org |

--- Comment #3 from José Fonseca  ---
Tentative fix out for review on

  http://lists.freedesktop.org/archives/mesa-dev/2015-June/086497.html

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: set override_version per api version override

2015-06-16 Thread Martin Peres

On 12/06/15 07:30, Tapani Pälli wrote:



On 06/11/2015 09:05 PM, Jordan Justen wrote:

On 2015-06-10 13:03:20, Jordan Justen wrote:

Whoops. I re-wrote this last night:

http://cgit.freedesktop.org/~jljusten/mesa/commit/?h=cs-33&id=3ebe7b79

On 2015-06-04 21:41:15, Tapani Pälli wrote:

Before 9b5e92f get_gl_override was called only once, but now it is
called for multiple APIs (GLES2, GL), version needs to be set always.

Signed-off-by: Tapani Pälli 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90797
---
  src/mesa/main/version.c | 36 ++--
  1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index 409e5ae..5e9943c 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -58,34 +58,42 @@ get_gl_override(gl_api api, int *version, bool 
*fwd_context,

? "MESA_GL_VERSION_OVERRIDE" : "MESA_GLES_VERSION_OVERRIDE";
 const char *version_str;
 int major, minor, n;
-   static int override_version = -1;
-   static bool fc_suffix = false;
-   static bool compat_suffix = false;
+   static struct override_info {
+  int version;
+  bool fc_suffix;
+  bool compat_suffix;
+   } override[API_OPENGL_LAST + 1] = {
+  { -1, false, false},
+  { -1, false, false},
+  { -1, false, false},
+  { -1, false, false},
+   };


I did this a bit differently. Rather than one for each API, I had one
per override env var.

If you think once per API is preferable, how about these changes to
your patch:

override[API_OPENGL_LAST + 1] => override[]

STATIC_ASSERT(ARRAY_SIZE(override) == API_OPENGL_LAST + 1);


Yep, this looks cleaner


Oh ... and with those changes,

Reviewed-by: Jordan Justen 


thanks Jordan!


Hey, can you please push this patch ASAP? It is getting very annoying to 
need to use MESA_GLES_VERSION_OVERRIDE instead of 
MESA_GL_VERSION_OVERRIDE to work around this bug...


Thanks :)
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: set override_version per api version override

2015-06-16 Thread Martin Peres

On 16/06/15 13:38, Martin Peres wrote:

On 12/06/15 07:30, Tapani Pälli wrote:



On 06/11/2015 09:05 PM, Jordan Justen wrote:

On 2015-06-10 13:03:20, Jordan Justen wrote:

Whoops. I re-wrote this last night:

http://cgit.freedesktop.org/~jljusten/mesa/commit/?h=cs-33&id=3ebe7b79

On 2015-06-04 21:41:15, Tapani Pälli wrote:

Before 9b5e92f get_gl_override was called only once, but now it is
called for multiple APIs (GLES2, GL), version needs to be set always.

Signed-off-by: Tapani Pälli 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90797
---
  src/mesa/main/version.c | 36 ++--
  1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index 409e5ae..5e9943c 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -58,34 +58,42 @@ get_gl_override(gl_api api, int *version, bool 
*fwd_context,

? "MESA_GL_VERSION_OVERRIDE" : "MESA_GLES_VERSION_OVERRIDE";
 const char *version_str;
 int major, minor, n;
-   static int override_version = -1;
-   static bool fc_suffix = false;
-   static bool compat_suffix = false;
+   static struct override_info {
+  int version;
+  bool fc_suffix;
+  bool compat_suffix;
+   } override[API_OPENGL_LAST + 1] = {
+  { -1, false, false},
+  { -1, false, false},
+  { -1, false, false},
+  { -1, false, false},
+   };


I did this a bit differently. Rather than one for each API, I had one
per override env var.

If you think once per API is preferable, how about these changes to
your patch:

override[API_OPENGL_LAST + 1] => override[]

STATIC_ASSERT(ARRAY_SIZE(override) == API_OPENGL_LAST + 1);


Yep, this looks cleaner


Oh ... and with those changes,

Reviewed-by: Jordan Justen 


thanks Jordan!


Hey, can you please push this patch ASAP? It is getting very annoying 
to need to use MESA_GLES_VERSION_OVERRIDE instead of 
MESA_GL_VERSION_OVERRIDE to work around this bug...


Thanks :)


Actually, I made the changes, reviewed, tested and pushed the patch. 
Sorry for the noise :)

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


Re: [Mesa-dev] [PATCH] winsys/radeon: Unmap GPU VM address range when destroying BO

2015-06-16 Thread Christian König

On 16.06.2015 10:56, Michel Dänzer wrote:

On 16.06.2015 17:34, Christian König wrote:

On 16.06.2015 10:28, Michel Dänzer wrote:

From: Michel Dänzer 

But only when doing so is safe according to the
RADEON_INFO_VA_UNMAP_WORKING kernel query.

This avoids GPU VM address range conflicts when the BO has other
references than the GEM handle being closed, e.g. when the BO is shared.

That actually doesn't really helps, it just masks the problem for now.
The other GEM handle could still require the address space just unmapped
and freed.

In theory, yes. In practice, I think only the Mesa driver actually uses
GPUVM addresses, not the other parts involved in these issues (the Xorg
radeon driver or the Android gralloc). The Mesa driver is careful not to
have several representations of the same BO.


Checking the latest code I think you're right. When the kernel returns 
RADEON_VA_RESULT_VA_EXIST we lockup the BO using it's VA address. 
Previously we just forced the same VA on a new BO object.



Or do you expect this might cause trouble with GL<->VDPAU or GL<->CL
interop?


Not really, they should use the same winsys and so the same BO 
representation.






What we would need to really clean that up is to make the VM mappings
per GEM handle like you suggested or allow multiple mappings per BO like
we did it for Amdgpu.

What kind of time-frame / effort do you think it would take to get that?


Doing it like Amdgpu is actually trivial to implement, we would just 
need to port the implementation back from Amdgpu. But the problem is 
that it would break the userspace ABI and some older mesa version 
wouldn't work any more because of this cause they couldn't detect any 
more that it's the same BO.


Doing the mapping per GEM handle might be an idea worth looking into, 
but I'm not sure how to approach that.






Another alternative is to teach radeon_bomgr_free_va that a certain
address range could be allocated to more than one handle.

What exactly do you have in mind for that? I don't think the winsys has
several representations of the same BO in the cases fixed by this patch,
and I'm not sure how it could account for external references.


Ah, right the BO could still be open by somebody else outside of mesa.

Since the code now looks up the BOs by VA we indeed shouldn't have any 
problems any more and your proposed solution should work fine.


Regards,
Christian.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 2/6] i965: Enable resource streamer for the batchbuffer

2015-06-16 Thread Abdiel Janulgue
Check first if the hardware and kernel supports resource streamer. If this
is allowed, tell the kernel to enable the resource streamer enable bit on
MI_BATCHBUFFER_START by specifying I915_EXEC_RESOURCE_STREAMER
execbuffer flags.

v2: - Use new I915_PARAM_HAS_RESOURCE_STREAMER ioctl to check if kernel
  supports RS (Ken).
- Add brw_device_info::has_resource_streamer and toggle it for
  Haswell, Broadwell, Cherryview, Skylake, and Broxton (Ken).
v3: - Update I915_PARAM_HAS_RESOURCE_STREAMER to match updated kernel.

Cc: kenn...@whitecape.org
Signed-off-by: Abdiel Janulgue 
---
 src/mesa/drivers/dri/i965/brw_context.c   |  5 +
 src/mesa/drivers/dri/i965/brw_context.h   |  1 +
 src/mesa/drivers/dri/i965/brw_device_info.c   |  5 -
 src/mesa/drivers/dri/i965/brw_device_info.h   |  1 +
 src/mesa/drivers/dri/i965/intel_batchbuffer.c |  8 +++-
 src/mesa/drivers/dri/i965/intel_screen.c  | 12 
 src/mesa/drivers/dri/i965/intel_screen.h  |  5 +
 7 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index f39b350..27abf0e 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -896,6 +896,11 @@ brwCreateContext(gl_api api,
 
brw->predicate.state = BRW_PREDICATE_STATE_RENDER;
 
+   brw->use_resource_streamer = devinfo->has_resource_streamer &&
+  screen->has_resource_streamer &&
+  (brw_env_var_as_boolean("INTEL_USE_HW_BT", false) ||
+   brw_env_var_as_boolean("INTEL_USE_GATHER", false));
+
ctx->VertexProgram._MaintainTnlProgram = true;
ctx->FragmentProgram._MaintainTexEnvProgram = true;
 
diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 01c4283..9754d7b 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1138,6 +1138,7 @@ struct brw_context
bool no_simd8;
bool use_rep_send;
bool scalar_vs;
+   bool use_resource_streamer;
 
/**
 * Some versions of Gen hardware don't do centroid interpolation correctly
diff --git a/src/mesa/drivers/dri/i965/brw_device_info.c 
b/src/mesa/drivers/dri/i965/brw_device_info.c
index 97243a4..35c347c 100644
--- a/src/mesa/drivers/dri/i965/brw_device_info.c
+++ b/src/mesa/drivers/dri/i965/brw_device_info.c
@@ -170,7 +170,8 @@ static const struct brw_device_info brw_device_info_byt = {
 #define HSW_FEATURES \
GEN7_FEATURES,\
.is_haswell = true,   \
-   .supports_simd16_3src = true
+   .supports_simd16_3src = true, \
+   .has_resource_streamer = true
 
 static const struct brw_device_info brw_device_info_hsw_gt1 = {
HSW_FEATURES, .gt = 1,
@@ -229,6 +230,7 @@ static const struct brw_device_info brw_device_info_hsw_gt3 
= {
 #define GEN8_FEATURES   \
.gen = 8,\
.has_hiz_and_separate_stencil = true,\
+   .has_resource_streamer = true,   \
.must_use_separate_stencil = true,   \
.has_llc = true, \
.has_pln = true, \
@@ -301,6 +303,7 @@ static const struct brw_device_info brw_device_info_chv = {
 #define GEN9_FEATURES   \
.gen = 9,\
.has_hiz_and_separate_stencil = true,\
+   .has_resource_streamer = true,   \
.must_use_separate_stencil = true,   \
.has_llc = true, \
.has_pln = true, \
diff --git a/src/mesa/drivers/dri/i965/brw_device_info.h 
b/src/mesa/drivers/dri/i965/brw_device_info.h
index 65c024c..b97cc4a 100644
--- a/src/mesa/drivers/dri/i965/brw_device_info.h
+++ b/src/mesa/drivers/dri/i965/brw_device_info.h
@@ -45,6 +45,7 @@ struct brw_device_info
bool has_compr4;
bool has_surface_tile_offset;
bool supports_simd16_3src;
+   bool has_resource_streamer;
 
/**
 * Quirks:
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c 
b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index ed659ed..cd34c6df 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -267,6 +267,11 @@ throttle(struct brw_context *brw)
}
 }
 
+/* Drop when RS headers get pulled to libdrm */
+#ifndef I915_EXEC_RESOURCE_STREAMER
+#define I915_EXEC_RESOURCE_STREAMER (1<<15)
+#endif
+
 /* TODO: Push this whole function into bufmgr.
  */
 static int
@@ -293,7 +298,8 @@ do_flush_locked(struct brw_context *brw)
   if (brw->gen >= 6 && batch->ring == BLT_RING) {
  flags = I915_EXEC_BLT;
   } else {
- flags = I915_EXEC_RENDER;
+ flags = I915_EXEC_RENDER |
+(brw->use_resource_streamer ? I915_EXEC_RESOURCE_STREAMER : 0);
   }
   if (batch->needs_so

Re: [Mesa-dev] [PATCH v3 2/6] i965: Enable resource streamer for the batchbuffer

2015-06-16 Thread Chris Wilson
On Tue, Jun 16, 2015 at 03:08:56PM +0300, Abdiel Janulgue wrote:
> Check first if the hardware and kernel supports resource streamer. If this
> is allowed, tell the kernel to enable the resource streamer enable bit on
> MI_BATCHBUFFER_START by specifying I915_EXEC_RESOURCE_STREAMER
> execbuffer flags.
> 
> v2: - Use new I915_PARAM_HAS_RESOURCE_STREAMER ioctl to check if kernel
>   supports RS (Ken).
> - Add brw_device_info::has_resource_streamer and toggle it for
>   Haswell, Broadwell, Cherryview, Skylake, and Broxton (Ken).
> v3: - Update I915_PARAM_HAS_RESOURCE_STREAMER to match updated kernel.
> 
> Cc: kenn...@whitecape.org
> Signed-off-by: Abdiel Janulgue 
> ---
>  src/mesa/drivers/dri/i965/brw_context.c   |  5 +
>  src/mesa/drivers/dri/i965/brw_context.h   |  1 +
>  src/mesa/drivers/dri/i965/brw_device_info.c   |  5 -
>  src/mesa/drivers/dri/i965/brw_device_info.h   |  1 +
>  src/mesa/drivers/dri/i965/intel_batchbuffer.c |  8 +++-
>  src/mesa/drivers/dri/i965/intel_screen.c  | 12 
>  src/mesa/drivers/dri/i965/intel_screen.h  |  5 +
>  7 files changed, 35 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
> b/src/mesa/drivers/dri/i965/brw_context.c
> index f39b350..27abf0e 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -896,6 +896,11 @@ brwCreateContext(gl_api api,
>  
> brw->predicate.state = BRW_PREDICATE_STATE_RENDER;
>  
> +   brw->use_resource_streamer = devinfo->has_resource_streamer &&
> +  screen->has_resource_streamer &&
> +  (brw_env_var_as_boolean("INTEL_USE_HW_BT", false) ||
> +   brw_env_var_as_boolean("INTEL_USE_GATHER", false));

Do you expect the envionment to change between contexts? Looks like all
of these can be used to compute screen->has_resource_streamer.
dev_info->has_resource_streamer is superfluous as well since it just
requires the kernel support.

>  /**
>   * This is the driver specific part of the createNewScreen entry point.
>   * Called when using DRI2.
> @@ -1420,6 +1425,13 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp)
> intelScreen->compiler = brw_compiler_create(intelScreen,
> intelScreen->devinfo);
>  
> +   if (intelScreen->devinfo->is_haswell || intelScreen->devinfo->gen >= 8) {
> +  getparam.param = I915_PARAM_HAS_RESOURCE_STREAMER;

So devinfo->has_resource_streamer was just a mirage after all.

> +  const int ret = drmIoctl(psp->fd, DRM_IOCTL_I915_GETPARAM, &getparam);
> +  intelScreen->has_resource_streamer = (ret != -1 || errno != EINVAL);

NO!!! You must always inspect the getparam.value. The trick is.

getparam.param = HAS_RESOURCE_STREAMER;
getparam.value = &val;

val = -1;
drmIoctl(psp->fd, DRM_IOCTL_I915_GETPARAM, &getparam);
intelScreen->has_resource_streamer = val > 0;

Hmm, now I need to double check the kernel patch for you GETPARAM.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [dri2proto] Declare DRI2ParamXHasBufferAge

2015-06-16 Thread Martin Peres

On 20/01/15 22:53, Ian Romanick wrote:

On 01/19/2015 03:00 AM, Chris Wilson wrote:

In order for X/DDX to reuse a driver specific field of the DRI2GetBuffers
reply, we need to declare the change in semantics. To indicate that the
flags field now continues the last swap buffers count instead, we
introduce the has-buffer-age parameter.

Signed-off-by: Chris Wilson 

Reviewed-by: Ian Romanick 



Reviewed-by: Martin Peres 

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


Re: [Mesa-dev] [PATCH v3 2/6] i965: Enable resource streamer for the batchbuffer

2015-06-16 Thread Abdiel Janulgue


On 06/16/2015 03:20 PM, Chris Wilson wrote:
> On Tue, Jun 16, 2015 at 03:08:56PM +0300, Abdiel Janulgue wrote:
>> Check first if the hardware and kernel supports resource streamer. If this
>> is allowed, tell the kernel to enable the resource streamer enable bit on
>> MI_BATCHBUFFER_START by specifying I915_EXEC_RESOURCE_STREAMER
>> execbuffer flags.
>>
>> v2: - Use new I915_PARAM_HAS_RESOURCE_STREAMER ioctl to check if kernel
>>   supports RS (Ken).
>> - Add brw_device_info::has_resource_streamer and toggle it for
>>   Haswell, Broadwell, Cherryview, Skylake, and Broxton (Ken).
>> v3: - Update I915_PARAM_HAS_RESOURCE_STREAMER to match updated kernel.
>>
>> Cc: kenn...@whitecape.org
>> Signed-off-by: Abdiel Janulgue 
>> ---
>>  src/mesa/drivers/dri/i965/brw_context.c   |  5 +
>>  src/mesa/drivers/dri/i965/brw_context.h   |  1 +
>>  src/mesa/drivers/dri/i965/brw_device_info.c   |  5 -
>>  src/mesa/drivers/dri/i965/brw_device_info.h   |  1 +
>>  src/mesa/drivers/dri/i965/intel_batchbuffer.c |  8 +++-
>>  src/mesa/drivers/dri/i965/intel_screen.c  | 12 
>>  src/mesa/drivers/dri/i965/intel_screen.h  |  5 +
>>  7 files changed, 35 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
>> b/src/mesa/drivers/dri/i965/brw_context.c
>> index f39b350..27abf0e 100644
>> --- a/src/mesa/drivers/dri/i965/brw_context.c
>> +++ b/src/mesa/drivers/dri/i965/brw_context.c
>> @@ -896,6 +896,11 @@ brwCreateContext(gl_api api,
>>  
>> brw->predicate.state = BRW_PREDICATE_STATE_RENDER;
>>  
>> +   brw->use_resource_streamer = devinfo->has_resource_streamer &&
>> +  screen->has_resource_streamer &&
>> +  (brw_env_var_as_boolean("INTEL_USE_HW_BT", false) ||
>> +   brw_env_var_as_boolean("INTEL_USE_GATHER", false));
> 
> Do you expect the envionment to change between contexts? Looks like all
> of these can be used to compute screen->has_resource_streamer.
> dev_info->has_resource_streamer is superfluous as well since it just
> requires the kernel support.

I think dev_info is supposed to be some "guide" that needs to be
consulted of whether HW supports certain features. This kernel check is
just there to see if the kernel has the support as well. But this is
just my opinion, I'll let Ken and others comment on this.

> 
>>  /**
>>   * This is the driver specific part of the createNewScreen entry point.
>>   * Called when using DRI2.
>> @@ -1420,6 +1425,13 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp)
>> intelScreen->compiler = brw_compiler_create(intelScreen,
>> intelScreen->devinfo);
>>  
>> +   if (intelScreen->devinfo->is_haswell || intelScreen->devinfo->gen >= 8) {
>> +  getparam.param = I915_PARAM_HAS_RESOURCE_STREAMER;
> 
> So devinfo->has_resource_streamer was just a mirage after all.
> 
>> +  const int ret = drmIoctl(psp->fd, DRM_IOCTL_I915_GETPARAM, &getparam);
>> +  intelScreen->has_resource_streamer = (ret != -1 || errno != EINVAL);
> 
> NO!!! You must always inspect the getparam.value. The trick is.
> 
> getparam.param = HAS_RESOURCE_STREAMER;
> getparam.value = &val;
> 
> val = -1;
> drmIoctl(psp->fd, DRM_IOCTL_I915_GETPARAM, &getparam);
> intelScreen->has_resource_streamer = val > 0;

Ok

> 
> Hmm, now I need to double check the kernel patch for you GETPARAM.
> -Chris
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCHv2 6/9] gallium: rename DRM_API_HANDLE_TYPE* WINSYS_HANDLE_TYPE*

2015-06-16 Thread Marc-André Lureau
Hi Marek

On Mon, Jun 15, 2015 at 10:21 PM, Marek Olšák  wrote:

> The idea of drm_driver.h and the DRM prefix is that it's meant to be
> Linux-specific, and winsys_handle should be considered an opaque
> structure by most state trackers. I think VMWare have their own
> definition of winsys_handle for Windows.
>

Is this in upstream? I couldn't find it.


>
> The terms like "KMS", "SHARED" (= FLINK), and FD (= DMABUF) are very
> DRM-specific, so they shouldn't be considered a standard gallium/winsys
> interface.
>

Perhaps they could be renamed so other terms, not drm-specific, could be
introduced?

DRM_API_HANDLE_TYPE_SHARED -> WINSYS_HANDLE_TYPE_DRM_FLINK
DRM_API_HANDLE_TYPE_KMS -> WINSYS_HANDLE_TYPE_DRM_KMS
DRM_API_HANDLE_TYPE_FD -> WINSYS_HANDLE_TYPE_DRM_DMABUF

It was possible to introduce a drisw-specific winsys struct before the gbm
"kms_swrast" driver, but since then both headers are used simultaneously,
so a common structure seems necessary.

thanks


-- 
Marc-André Lureau
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] i965/skl: Fix aligning mt->total_width to the block size

2015-06-16 Thread Neil Roberts
brw_miptree_layout_2d tries to ensure that mt->total_width is a
multiple of the compressed block size, presumably because it wouldn't
be possible to make an image that has a fraction of a block. However
it was doing this by aligning mt->total_width to align_w. Previously
align_w has been used as a shortcut for getting the block width
because before Gen9 the block width was always equal to the alignment.
Commit 4ab8d59a2 tried to fix these cases to use the block width
instead of the alignment but it missed this case.

I think in practice this probably won't make any difference because
the buffer for the texture will be allocated to be large enough to
contain the entire pitch and libdrm aligns the pitch to the tile width
anyway. However I think the patch is worth having to make the
intention clearer.
---
 src/mesa/drivers/dri/i965/brw_tex_layout.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c 
b/src/mesa/drivers/dri/i965/brw_tex_layout.c
index 1e7d8a1..dbb6cef 100644
--- a/src/mesa/drivers/dri/i965/brw_tex_layout.c
+++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c
@@ -366,9 +366,8 @@ brw_miptree_layout_2d(struct intel_mipmap_tree *mt)
 
mt->total_width = mt->physical_width0;
 
-   if (mt->compressed) {
-   mt->total_width = ALIGN(mt->physical_width0, mt->align_w);
-   }
+   if (mt->compressed)
+   mt->total_width = ALIGN(mt->total_width, bw);
 
/* May need to adjust width to accommodate the placement of
 * the 2nd mipmap.  This occurs when the alignment
-- 
1.9.3

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


Re: [Mesa-dev] [xorg 1/3] dri2: Allow GetBuffers to match any format

2015-06-16 Thread Martin Peres

On 20/01/15 22:49, Ian Romanick wrote:

On 01/19/2015 03:00 AM, Chris Wilson wrote:

Since the introduction of DRI2GetBuffersWithFormat, the old
DRI2GetBuffers interface would always recreate all buffers all the time
as it was no longer agnostic to the format value being set by the DDXes.
This causes an issue with clients intermixing the two requests,
rendering any sharing or caching of buffers (e.g. for triple buffering)
void.

Signed-off-by: Chris Wilson 
---
  hw/xfree86/dri2/dri2.c | 13 -
  1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 43a1899..f9f594d 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -464,14 +464,16 @@ find_attachment(DRI2DrawablePtr pPriv, unsigned 
attachment)
  static Bool
  allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
   DRI2DrawablePtr pPriv,
- unsigned int attachment, unsigned int format,
+ unsigned int attachment,
+ int has_format, unsigned int format,
   int dimensions_match, DRI2BufferPtr * buffer)
  {
  int old_buf = find_attachment(pPriv, attachment);
  
  if ((old_buf < 0)

  || attachment == DRI2BufferFrontLeft
-|| !dimensions_match || (pPriv->buffers[old_buf]->format != format)) {
+|| !dimensions_match
+|| (has_format && pPriv->buffers[old_buf]->format != format)) {
  *buffer = create_buffer(ds, pDraw, attachment, format);

Shouldn't the create_buffer change if !has_format?  If !has_format and,
say, !dimensions_match, create_buffer will get format = 0 when it should
get format = pPriv->buffers[old_buf]->format.  Right?


This is still a problem in the current patchset that I have. Since the 
client did not specifically ask for a certain format, why not increase 
the likeliness of us being able to reuse the buffer later on by using a 
format that the application already asked before?




Another alternative would be to have the caller always pass a format:
either the format supplied in the protocol or the format of the old
buffer.  That might be more messy.  Dunno.


  return TRUE;
  
@@ -549,7 +551,8 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,

  const unsigned format = (has_format) ? *(attachments++) : 0;
  
  if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment,

- format, dimensions_match, &buffers[i]))
+ has_format, format, dimensions_match,
+ &buffers[i]))
  buffers_changed = 1;
  
  if (buffers[i] == NULL)

@@ -584,7 +587,7 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
  
  if (need_real_front > 0) {

  if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft,
- front_format, dimensions_match,
+ has_format, front_format, 
dimensions_match,
   &buffers[i]))
  buffers_changed = 1;
  
@@ -595,7 +598,7 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
  
  if (need_fake_front > 0) {

  if (allocate_or_reuse_buffer(pDraw, ds, pPriv, 
DRI2BufferFakeFrontLeft,
- front_format, dimensions_match,
+ has_format, front_format, 
dimensions_match,
   &buffers[i]))
  buffers_changed = 1;
  

___
dri-devel mailing list
dri-de...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


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


[Mesa-dev] Fwd: [PATCHv2 6/9] gallium: rename DRM_API_HANDLE_TYPE* WINSYS_HANDLE_TYPE*

2015-06-16 Thread Marek Olšák
On Tue, Jun 16, 2015 at 2:42 PM, Marc-André Lureau
 wrote:
> Hi Marek
>
> On Mon, Jun 15, 2015 at 10:21 PM, Marek Olšák  wrote:
>>
>> The idea of drm_driver.h and the DRM prefix is that it's meant to be
>> Linux-specific, and winsys_handle should be considered an opaque
>> structure by most state trackers. I think VMWare have their own
>> definition of winsys_handle for Windows.
>
>
> Is this in upstream? I couldn't find it.

I don't think so.

>
>>
>>
>> The terms like "KMS", "SHARED" (= FLINK), and FD (= DMABUF) are very
>> DRM-specific, so they shouldn't be considered a standard gallium/winsys
>> interface.
>
>
> Perhaps they could be renamed so other terms, not drm-specific, could be
> introduced?
>
> DRM_API_HANDLE_TYPE_SHARED -> WINSYS_HANDLE_TYPE_DRM_FLINK
> DRM_API_HANDLE_TYPE_KMS -> WINSYS_HANDLE_TYPE_DRM_KMS
> DRM_API_HANDLE_TYPE_FD -> WINSYS_HANDLE_TYPE_DRM_DMABUF
>
> It was possible to introduce a drisw-specific winsys struct before the gbm
> "kms_swrast" driver, but since then both headers are used simultaneously, so
> a common structure seems necessary.

It's still Linux-specific though, so DRM_* seems more
appropriate than WINSYS_HANDLE_*.

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


Re: [Mesa-dev] Fwd: [PATCHv2 6/9] gallium: rename DRM_API_HANDLE_TYPE* WINSYS_HANDLE_TYPE*

2015-06-16 Thread Marc-André Lureau
Hi

On Tue, Jun 16, 2015 at 3:33 PM, Marek Olšák  wrote:

> On Tue, Jun 16, 2015 at 2:42 PM, Marc-André Lureau
>  wrote:
> > Hi Marek
> >
> > On Mon, Jun 15, 2015 at 10:21 PM, Marek Olšák  wrote:
> >>
> >> The idea of drm_driver.h and the DRM prefix is that it's meant to be
> >> Linux-specific, and winsys_handle should be considered an opaque
> >> structure by most state trackers. I think VMWare have their own
> >> definition of winsys_handle for Windows.
> >
> >
> > Is this in upstream? I couldn't find it.
>
> I don't think so.
>

If they have downstream patch to mesa, it's unfair to make such guesses to
reject a patch. They should speak up and propose an alternative in this
case, or simply patch it differently.


> >
> >>
> >>
> >> The terms like "KMS", "SHARED" (= FLINK), and FD (= DMABUF) are very
> >> DRM-specific, so they shouldn't be considered a standard gallium/winsys
> >> interface.
> >
> >
> > Perhaps they could be renamed so other terms, not drm-specific, could be
> > introduced?
> >
> > DRM_API_HANDLE_TYPE_SHARED -> WINSYS_HANDLE_TYPE_DRM_FLINK
> > DRM_API_HANDLE_TYPE_KMS -> WINSYS_HANDLE_TYPE_DRM_KMS
> > DRM_API_HANDLE_TYPE_FD -> WINSYS_HANDLE_TYPE_DRM_DMABUF
> >
> > It was possible to introduce a drisw-specific winsys struct before the
> gbm
> > "kms_swrast" driver, but since then both headers are used
> simultaneously, so
> > a common structure seems necessary.
>
> It's still Linux-specific though, so DRM_* seems more
> appropriate than WINSYS_HANDLE_*.
>

Ok, but my point is to not make it drm specific, so a shmid handle can be
use by drisw.

-- 
Marc-André Lureau
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Fwd: [PATCHv2 6/9] gallium: rename DRM_API_HANDLE_TYPE* WINSYS_HANDLE_TYPE*

2015-06-16 Thread Marek Olšák
On Tue, Jun 16, 2015 at 3:44 PM, Marc-André Lureau
 wrote:
> Hi
>
> On Tue, Jun 16, 2015 at 3:33 PM, Marek Olšák  wrote:
>>
>> On Tue, Jun 16, 2015 at 2:42 PM, Marc-André Lureau
>>  wrote:
>> > Hi Marek
>> >
>> > On Mon, Jun 15, 2015 at 10:21 PM, Marek Olšák  wrote:
>> >>
>> >> The idea of drm_driver.h and the DRM prefix is that it's meant to be
>> >> Linux-specific, and winsys_handle should be considered an opaque
>> >> structure by most state trackers. I think VMWare have their own
>> >> definition of winsys_handle for Windows.
>> >
>> >
>> > Is this in upstream? I couldn't find it.
>>
>> I don't think so.
>
>
> If they have downstream patch to mesa, it's unfair to make such guesses to
> reject a patch. They should speak up and propose an alternative in this
> case, or simply patch it differently.
>
>>
>> >
>> >>
>> >>
>> >> The terms like "KMS", "SHARED" (= FLINK), and FD (= DMABUF) are very
>> >> DRM-specific, so they shouldn't be considered a standard gallium/winsys
>> >> interface.
>> >
>> >
>> > Perhaps they could be renamed so other terms, not drm-specific, could be
>> > introduced?
>> >
>> > DRM_API_HANDLE_TYPE_SHARED -> WINSYS_HANDLE_TYPE_DRM_FLINK
>> > DRM_API_HANDLE_TYPE_KMS -> WINSYS_HANDLE_TYPE_DRM_KMS
>> > DRM_API_HANDLE_TYPE_FD -> WINSYS_HANDLE_TYPE_DRM_DMABUF
>> >
>> > It was possible to introduce a drisw-specific winsys struct before the
>> > gbm
>> > "kms_swrast" driver, but since then both headers are used
>> > simultaneously, so
>> > a common structure seems necessary.
>>
>> It's still Linux-specific though, so DRM_* seems more
>> appropriate than WINSYS_HANDLE_*.
>
>
> Ok, but my point is to not make it drm specific, so a shmid handle can be
> use by drisw.

OK, I suppose your latest proposition of renaming the types to
WINSYS_HANDLE_TYPE_DRM_* makes sense here.

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


[Mesa-dev] [Bug 71199] [llvmpipe] piglit gl-1.4-polygon-offset regression

2015-06-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=71199

--- Comment #10 from José Fonseca  ---
On me Mesa DRI Intel(R) Haswell Mobile I actually get the reverse problem:

$ ./bin/gl-1.4-polygon-offset -auto
Actual MRD is too large (may waste depth-buffer range)

Ideal  MRD at near plane is 5.960283e-08 (nominally 1 bit)
Actual MRD at near plane is 1.192093e-07 (nominally 2 bits)
Ideal  MRD at infinity is 4.353401e-08 (nominally 1 bit)
Actual MRD at infinity is 1.192093e-07 (nominally 2 bits)

PIGLIT: {"result": "fail" }

So the test itself doesn't seem to be limited to 1 bit as I considered.

Still no idea on how to fix it.  I'm reluctant just to bump MRD on llvmpipe, as
I'm afraid it will cause problems with different state trackers.

It's not a huge deal neither.

In short, I'm afraid there's little chance for a fix any time soon..

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glsl: Fail linkage when UBO exceeds GL_MAX_UNIFORM_BLOCK_SIZE.

2015-06-16 Thread Roland Scheidegger
This looks like a good idea to me.
That said, llvmpipe would still crash if the declared size in the shader
wouldn't exceed the max uniform block size, but the bound buffer does
IIRC (the test doesn't test this but could be easily modified to do so).
So, I'm wondering if we should do both - fail to link if the declared
size exceeds the limit, and just limit the size we copy in llvmpipe to
the limit, though it's possible this would require some more changes to
be really safe so we don't try to access such elements (with indirect
access, though we don't verify direct ones at all) in the shader.

Reviewed-by: Roland Scheidegger 


Am 16.06.2015 um 12:29 schrieb Jose Fonseca:
> It's not totally clear whether other Mesa drivers can safely cope with
> over-sized UBOs, but at least for llvmpipe receiving a UBO larger than
> its limit causes problems, as it won't fit into its internal display
> lists.
> 
> This fixes piglit "arb_uniform_buffer_object-maxuniformblocksize
> fsexceed" without regressions for llvmpipe.
> 
> NVIDIA driver also fails to link the shader from
> "arb_uniform_buffer_object-maxuniformblocksize fsexceed".
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65525
> 
> PS: I don't recommend cherry-picking this for Mesa stable, as some app
> might inadvertently been relying on UBOs larger than
> GL_MAX_UNIFORM_BLOCK_SIZE to work on other drivers, so even if this
> commit is universally accepted it's probably best to let it mature in
> master for a while.
> ---
>  src/glsl/linker.cpp | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
> index 9978380..4a726d4 100644
> --- a/src/glsl/linker.cpp
> +++ b/src/glsl/linker.cpp
> @@ -2355,6 +2355,13 @@ check_resources(struct gl_context *ctx, struct 
> gl_shader_program *prog)
> unsigned total_uniform_blocks = 0;
>  
> for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
> +  if (prog->UniformBlocks[i].UniformBufferSize > 
> ctx->Const.MaxUniformBlockSize) {
> + linker_error(prog, "Uniform block %s too big (%d/%d)\n",
> +  prog->UniformBlocks[i].Name,
> +  prog->UniformBlocks[i].UniformBufferSize,
> +  ctx->Const.MaxUniformBlockSize);
> +  }
> +
>for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) {
>if (prog->UniformBlockStageIndex[j][i] != -1) {
>   blocks[j]++;
> 

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


Re: [Mesa-dev] [PATCH] glsl: Fail linkage when UBO exceeds GL_MAX_UNIFORM_BLOCK_SIZE.

2015-06-16 Thread Ilia Mirkin
On Tue, Jun 16, 2015 at 10:22 AM, Roland Scheidegger  wrote:
> This looks like a good idea to me.
> That said, llvmpipe would still crash if the declared size in the shader
> wouldn't exceed the max uniform block size, but the bound buffer does
> IIRC (the test doesn't test this but could be easily modified to do so).
> So, I'm wondering if we should do both - fail to link if the declared
> size exceeds the limit, and just limit the size we copy in llvmpipe to
> the limit, though it's possible this would require some more changes to
> be really safe so we don't try to access such elements (with indirect
> access, though we don't verify direct ones at all) in the shader.

Not to derail this too much, but just FWIW I just checked this patch
in to prevent gpu errors:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b24388647f626a5cad10fd48e61335ed26a8560

Didn't fix the trace, but at least it no longer complained about
illegal sizes. Trace available at

http://people.freedesktop.org/~imirkin/traces/gzdoom.trace

It just renders black now. The claim is that the game (but not
necessarily the trace) works OK on NVIDIA blob drivers. I haven't
analyzed the trace in much detail yet.

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


Re: [Mesa-dev] Fwd: [PATCHv2 6/9] gallium: rename DRM_API_HANDLE_TYPE* WINSYS_HANDLE_TYPE*

2015-06-16 Thread Brian Paul

On 06/16/2015 07:44 AM, Marc-André Lureau wrote:

Hi

On Tue, Jun 16, 2015 at 3:33 PM, Marek Olšák mailto:mar...@gmail.com>> wrote:

On Tue, Jun 16, 2015 at 2:42 PM, Marc-André Lureau
mailto:marcandre.lur...@gmail.com>> wrote:
 > Hi Marek
 >
 > On Mon, Jun 15, 2015 at 10:21 PM, Marek Olšák mailto:mar...@gmail.com>> wrote:
 >>
 >> The idea of drm_driver.h and the DRM prefix is that it's meant to be
 >> Linux-specific, and winsys_handle should be considered an opaque
 >> structure by most state trackers. I think VMWare have their own
 >> definition of winsys_handle for Windows.
 >
 >
 > Is this in upstream? I couldn't find it.

I don't think so.


If they have downstream patch to mesa, it's unfair to make such guesses
to reject a patch. They should speak up and propose an alternative in
this case, or simply patch it differently.


I don't think these changes will cause us any trouble.

Maybe the WINSYS_HANDLE_TYPE_* values should be an enum type so that the 
compiler can catch unhandled switch cases and gdb can display the names 
instead of numbers.


-Brian

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


Re: [Mesa-dev] [Mesa-stable] [PATCH] egl/x11: Set version of swrastLoader to 2

2015-06-16 Thread Ian Romanick
Gak... I thought we fixed all of those. :(

Reviewed-by: Ian Romanick 

On 06/15/2015 08:08 PM, Boyan Ding wrote:
> which it actually implements instead of the newest version defined in
> dri_interface.h
> 
> Cc: "10.5 10.6" 
> Signed-off-by: Boyan Ding 
> ---
>  src/egl/drivers/dri2/platform_x11.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/egl/drivers/dri2/platform_x11.c 
> b/src/egl/drivers/dri2/platform_x11.c
> index f1101d6..53717b3 100644
> --- a/src/egl/drivers/dri2/platform_x11.c
> +++ b/src/egl/drivers/dri2/platform_x11.c
> @@ -1112,7 +1112,7 @@ dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay 
> *disp)
>goto cleanup_conn;
>  
> dri2_dpy->swrast_loader_extension.base.name = __DRI_SWRAST_LOADER;
> -   dri2_dpy->swrast_loader_extension.base.version = 
> __DRI_SWRAST_LOADER_VERSION;
> +   dri2_dpy->swrast_loader_extension.base.version = 2;
> dri2_dpy->swrast_loader_extension.getDrawableInfo = swrastGetDrawableInfo;
> dri2_dpy->swrast_loader_extension.putImage = swrastPutImage;
> dri2_dpy->swrast_loader_extension.getImage = swrastGetImage;
> 

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


Re: [Mesa-dev] [PATCH] glsl: Fail linkage when UBO exceeds GL_MAX_UNIFORM_BLOCK_SIZE.

2015-06-16 Thread Jose Fonseca

On 16/06/15 15:29, Ilia Mirkin wrote:

On Tue, Jun 16, 2015 at 10:22 AM, Roland Scheidegger  wrote:

This looks like a good idea to me.
That said, llvmpipe would still crash if the declared size in the shader
wouldn't exceed the max uniform block size, but the bound buffer does
IIRC (the test doesn't test this but could be easily modified to do so).
So, I'm wondering if we should do both - fail to link if the declared
size exceeds the limit, and just limit the size we copy in llvmpipe to
the limit, though it's possible this would require some more changes to
be really safe so we don't try to access such elements (with indirect
access, though we don't verify direct ones at all) in the shader.


Not to derail this too much, but just FWIW I just checked this patch
in to prevent gpu errors:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b24388647f626a5cad10fd48e61335ed26a8560

Didn't fix the trace, but at least it no longer complained about
illegal sizes. Trace available at

http://people.freedesktop.org/~imirkin/traces/gzdoom.trace

It just renders black now. The claim is that the game (but not
necessarily the trace) works OK on NVIDIA blob drivers. I haven't
analyzed the trace in much detail yet.

   -ilia



Interesting. I don't get errors from NVIDIA.  So it does look like 
binding large UBOs is treated differently.  (And understandibly, since 
one can bind a range of a UBO too.)


I think Roland's right, in llvmpipe we'll need to handle that better by 
truncating the constant buffer copied to the display lists.


BTW, the trace use PERSISTENT mappings, which aren't supported in 
apitrace.  So I suspect it will never render well.


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


[Mesa-dev] [PATCH 07/14] mesa: Set green, blue channels to zero only for formats with these components

2015-06-16 Thread Anuj Phogat
Signed-off-by: Anuj Phogat 
---
 src/mesa/drivers/common/meta.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 214a68a..fceb25d 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -3132,9 +3132,16 @@ decompress_texture_image(struct gl_context *ctx,
* returned as red and two-channel texture values are returned as
* red/alpha.
*/
-  if ((baseTexFormat == GL_LUMINANCE ||
-   baseTexFormat == GL_LUMINANCE_ALPHA ||
-   baseTexFormat == GL_INTENSITY) ||
+  if (((baseTexFormat == GL_LUMINANCE ||
+baseTexFormat == GL_LUMINANCE_ALPHA ||
+baseTexFormat == GL_INTENSITY) &&
+   (destBaseFormat == GL_RGBA ||
+destBaseFormat == GL_RGB ||
+destBaseFormat == GL_RG ||
+destBaseFormat == GL_GREEN ||
+destBaseFormat == GL_BLUE ||
+destBaseFormat == GL_BGRA ||
+destBaseFormat == GL_BGR)) ||
   /* If we're reading back an RGB(A) texture (using glGetTexImage) as
   * luminance then we need to return L=tex(R).
   */
-- 
1.9.3

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


[Mesa-dev] [PATCH 05/14] meta: Abort meta pbo path if readpixels need signed-unsigned conversion

2015-06-16 Thread Anuj Phogat
Without this patch, piglit test fbo_integer_readpixels_sint_uint fails, when
forced to use the meta pbo path.

Signed-off-by: Anuj Phogat 
Cc: 
---
 src/mesa/drivers/common/meta_tex_subimage.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/mesa/drivers/common/meta_tex_subimage.c 
b/src/mesa/drivers/common/meta_tex_subimage.c
index 00364f8..84cbc50 100644
--- a/src/mesa/drivers/common/meta_tex_subimage.c
+++ b/src/mesa/drivers/common/meta_tex_subimage.c
@@ -283,6 +283,9 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
GLuint dims,
 
   if (_mesa_need_rgb_to_luminance_conversion(rb->Format, format))
  return false;
+
+  if (_mesa_need_signed_unsigned_int_conversion(rb->Format, format, type))
+ return false;
}
 
/* For arrays, use a tall (height * depth) 2D texture but taking into
-- 
1.9.3

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


[Mesa-dev] [PATCH 09/14] meta: Use _mesa_unpack_format_to_base_format() to handle integer formats

2015-06-16 Thread Anuj Phogat
_mesa_base_tex_format() doesn't handle GL_*_INTEGER formats.

Signed-off-by: Anuj Phogat 
---
 src/mesa/drivers/common/meta.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index fceb25d..c9e58d8 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -3123,7 +3123,7 @@ decompress_texture_image(struct gl_context *ctx,
/* read pixels from renderbuffer */
{
   GLenum baseTexFormat = texImage->_BaseFormat;
-  GLenum destBaseFormat = _mesa_base_tex_format(ctx, destFormat);
+  GLenum destBaseFormat = _mesa_unpack_format_to_base_format(destFormat);
 
   /* The pixel transfer state will be set to default values at this point
* (see MESA_META_PIXEL_TRANSFER) so pixel transfer ops are effectively
@@ -3149,9 +3149,7 @@ decompress_texture_image(struct gl_context *ctx,
 baseTexFormat == GL_RGB  ||
 baseTexFormat == GL_RG) &&
   (destBaseFormat == GL_LUMINANCE ||
-   destBaseFormat == GL_LUMINANCE_ALPHA ||
-   destBaseFormat == GL_LUMINANCE_INTEGER_EXT ||
-   destBaseFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT))) {
+   destBaseFormat == GL_LUMINANCE_ALPHA))) {
  /* Green and blue must be zero */
  _mesa_PixelTransferf(GL_GREEN_SCALE, 0.0f);
  _mesa_PixelTransferf(GL_BLUE_SCALE, 0.0f);
-- 
1.9.3

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


[Mesa-dev] [PATCH 10/14] mesa: Add a helper function _mesa_need_luminance_to_rgb_conversion()

2015-06-16 Thread Anuj Phogat
Signed-off-by: Anuj Phogat 
Cc: 
---
 src/mesa/main/readpix.c | 18 ++
 src/mesa/main/readpix.h |  4 
 2 files changed, 22 insertions(+)

diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index 1038983..c98975f 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -60,6 +60,24 @@ _mesa_need_rgb_to_luminance_conversion(mesa_format 
texFormat, GLenum format)
format == GL_LUMINANCE_ALPHA_INTEGER_EXT);
 }
 
+/**
+ * Return true if the conversion L,I to RGB conversion is needed.
+ */
+GLboolean
+_mesa_need_luminance_to_rgb_conversion(GLenum srcBaseFormat,
+   GLenum dstBaseFormat)
+{
+   return (srcBaseFormat == GL_LUMINANCE ||
+   srcBaseFormat == GL_LUMINANCE_ALPHA ||
+   srcBaseFormat == GL_INTENSITY) &&
+  (dstBaseFormat == GL_GREEN ||
+   dstBaseFormat == GL_BLUE ||
+   dstBaseFormat == GL_RG ||
+   dstBaseFormat == GL_RGB ||
+   dstBaseFormat == GL_BGR ||
+   dstBaseFormat == GL_RGBA ||
+   dstBaseFormat == GL_BGRA);
+}
 
 /**
  * Return transfer op flags for this ReadPixels operation.
diff --git a/src/mesa/main/readpix.h b/src/mesa/main/readpix.h
index a93e263..b59decd 100644
--- a/src/mesa/main/readpix.h
+++ b/src/mesa/main/readpix.h
@@ -40,6 +40,10 @@ _mesa_readpixels_needs_slow_path(const struct gl_context 
*ctx, GLenum format,
 extern GLboolean
 _mesa_need_rgb_to_luminance_conversion(mesa_format texFormat, GLenum format);
 
+extern GLboolean
+_mesa_need_luminance_to_rgb_conversion(GLenum srcBaseFormat,
+   GLenum dstBaseFormat);
+
 extern GLbitfield
 _mesa_get_readpixels_transfer_ops(const struct gl_context *ctx,
   mesa_format texFormat,
-- 
1.9.3

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


[Mesa-dev] [PATCH 12/14] meta: Fix reading luminance texture as rgba in _mesa_meta_pbo_GetTexSubImage()

2015-06-16 Thread Anuj Phogat
After recent addition of pbo testing in piglit test getteximage-luminance,
it fails on i965. This patch makes a sub test pass.

This patch adds additional clear color operation which I think is better
than falling back to software path.

Signed-off-by: Anuj Phogat 
Cc: 
---
 src/mesa/drivers/common/meta_tex_subimage.c | 35 +++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/common/meta_tex_subimage.c 
b/src/mesa/drivers/common/meta_tex_subimage.c
index ccb7dfb..6d52014 100644
--- a/src/mesa/drivers/common/meta_tex_subimage.c
+++ b/src/mesa/drivers/common/meta_tex_subimage.c
@@ -28,6 +28,7 @@
 #include "blend.h"
 #include "bufferobj.h"
 #include "buffers.h"
+#include "clear.h"
 #include "fbobject.h"
 #include "glformats.h"
 #include "glheader.h"
@@ -261,8 +262,9 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
GLuint dims,
int full_height, image_height;
struct gl_texture_image *pbo_tex_image;
struct gl_renderbuffer *rb = NULL;
-   GLenum status;
-   bool success = false;
+   GLenum status, src_base_format;
+   bool success = false, clear_channels_to_zero = false;
+   float save_clear_color[4];
int z;
 
if (!_mesa_is_bufferobj(packing->BufferObj))
@@ -355,6 +357,26 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
GLuint dims,
   GL_COLOR_BUFFER_BIT, GL_NEAREST))
   goto fail;
 
+   src_base_format = tex_image ?
+ tex_image->_BaseFormat :
+ ctx->ReadBuffer->_ColorReadBuffer->_BaseFormat;
+
+   /* Depending on the base formats involved we might need to rebase some
+* values. For example if we download from a Luminance format to RGBA
+* format, we want G=0 and B=0.
+*/
+   clear_channels_to_zero =
+  _mesa_need_luminance_to_rgb_conversion(src_base_format,
+ pbo_tex_image->_BaseFormat);
+
+   if (clear_channels_to_zero) {
+  memcpy(save_clear_color, ctx->Color.ClearColor.f, 4 * sizeof(float));
+  /* Clear the Green, Blue channels. */
+  _mesa_ColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE);
+  _mesa_ClearColor(0.0, 0.0, 0.0, 1.0);
+  _mesa_Clear(GL_COLOR_BUFFER_BIT);
+   }
+
for (z = 1; z < depth; z++) {
   _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
 tex_image, zoffset + z);
@@ -367,6 +389,15 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
GLuint dims,
  0, z * image_height,
  width, z * image_height + height,
  GL_COLOR_BUFFER_BIT, GL_NEAREST);
+  if (clear_channels_to_zero)
+ _mesa_Clear(GL_COLOR_BUFFER_BIT);
+   }
+
+   /* Unmask the color channels and restore the saved clear color values. */
+   if (clear_channels_to_zero) {
+  _mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+  _mesa_ClearColor(save_clear_color[0], save_clear_color[1],
+   save_clear_color[2], save_clear_color[3]);
}
 
success = true;
-- 
1.9.3

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


[Mesa-dev] [PATCH 01/14] mesa: Turn get_readpixels_transfer_ops() in to a global function

2015-06-16 Thread Anuj Phogat
This utility function is utilized in a later patch.

Signed-off-by: Anuj Phogat 
Cc: 
---
Jenkins showed no piglit regressions with this series.

 src/mesa/main/readpix.c | 14 --
 src/mesa/main/readpix.h |  6 ++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index a3357cd..caa2648 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -64,9 +64,11 @@ _mesa_need_rgb_to_luminance_conversion(mesa_format 
texFormat, GLenum format)
 /**
  * Return transfer op flags for this ReadPixels operation.
  */
-static GLbitfield
-get_readpixels_transfer_ops(const struct gl_context *ctx, mesa_format 
texFormat,
-GLenum format, GLenum type, GLboolean uses_blit)
+GLbitfield
+_mesa_get_readpixels_transfer_ops(const struct gl_context *ctx,
+  mesa_format texFormat,
+  GLenum format, GLenum type,
+  GLboolean uses_blit)
 {
GLbitfield transferOps = ctx->_ImageTransferState;
 
@@ -169,7 +171,7 @@ _mesa_readpixels_needs_slow_path(const struct gl_context 
*ctx, GLenum format,
   }
 
   /* And finally, see if there are any transfer ops. */
-  return get_readpixels_transfer_ops(ctx, rb->Format, format, type,
+  return _mesa_get_readpixels_transfer_ops(ctx, rb->Format, format, type,
  uses_blit) != 0;
}
return GL_FALSE;
@@ -436,8 +438,8 @@ read_rgba_pixels( struct gl_context *ctx,
if (!rb)
   return;
 
-   transferOps = get_readpixels_transfer_ops(ctx, rb->Format, format, type,
- GL_FALSE);
+   transferOps = _mesa_get_readpixels_transfer_ops(ctx, rb->Format, format,
+   type, GL_FALSE);
/* Describe the dst format */
dst_is_integer = _mesa_is_enum_format_integer(format);
dst_stride = _mesa_image_row_stride(packing, width, format, type);
diff --git a/src/mesa/main/readpix.h b/src/mesa/main/readpix.h
index 1636dd9..f894036 100644
--- a/src/mesa/main/readpix.h
+++ b/src/mesa/main/readpix.h
@@ -40,6 +40,12 @@ _mesa_readpixels_needs_slow_path(const struct gl_context 
*ctx, GLenum format,
 extern GLboolean
 _mesa_need_rgb_to_luminance_conversion(mesa_format texFormat, GLenum format);
 
+extern GLbitfield
+_mesa_get_readpixels_transfer_ops(const struct gl_context *ctx,
+  mesa_format texFormat,
+  GLenum format, GLenum type,
+  GLboolean uses_blit);
+
 extern void
 _mesa_readpixels(struct gl_context *ctx,
  GLint x, GLint y, GLsizei width, GLsizei height,
-- 
1.9.3

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


[Mesa-dev] [PATCH 14/14] meta: Use _mesa_need_rgb_to_luminance_conversion() in decompress_texture_image()

2015-06-16 Thread Anuj Phogat
Signed-off-by: Anuj Phogat 
---
 src/mesa/drivers/common/meta.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 6108d98..e123500 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -3137,11 +3137,8 @@ decompress_texture_image(struct gl_context *ctx,
   /* If we're reading back an RGB(A) texture (using glGetTexImage) as
   * luminance then we need to return L=tex(R).
   */
-  ((baseTexFormat == GL_RGBA ||
-baseTexFormat == GL_RGB  ||
-baseTexFormat == GL_RG) &&
-  (destBaseFormat == GL_LUMINANCE ||
-   destBaseFormat == GL_LUMINANCE_ALPHA))) {
+  _mesa_need_rgb_to_luminance_conversion(baseTexFormat,
+ destBaseFormat)) {
  /* Green and blue must be zero */
  _mesa_PixelTransferf(GL_GREEN_SCALE, 0.0f);
  _mesa_PixelTransferf(GL_BLUE_SCALE, 0.0f);
-- 
1.9.3

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


[Mesa-dev] [PATCH 06/14] meta: Don't do fragment color clamping in case of ReadPixels

2015-06-16 Thread Anuj Phogat
Without this patch, piglit test arb_color_buffer_float-readpixels
fails, when forced to use the meta pbo path.

Signed-off-by: Anuj Phogat 
Cc: 
---
 src/mesa/drivers/common/meta_tex_subimage.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/mesa/drivers/common/meta_tex_subimage.c 
b/src/mesa/drivers/common/meta_tex_subimage.c
index 84cbc50..ccb7dfb 100644
--- a/src/mesa/drivers/common/meta_tex_subimage.c
+++ b/src/mesa/drivers/common/meta_tex_subimage.c
@@ -25,6 +25,7 @@
  *Jason Ekstrand 
  */
 
+#include "blend.h"
 #include "bufferobj.h"
 #include "buffers.h"
 #include "fbobject.h"
@@ -305,6 +306,10 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
GLuint dims,
_mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER |
MESA_META_PIXEL_STORE));
 
+   /* GL_CLAMP_FRAGMENT_COLOR doesn't affect ReadPixels. */
+   if (!tex_image && ctx->Extensions.ARB_color_buffer_float)
+  _mesa_ClampColor(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE);
+
_mesa_GenFramebuffers(2, fbos);
 
if (tex_image && tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) {
-- 
1.9.3

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


[Mesa-dev] [PATCH 08/14] mesa: Add a helper function _mesa_unpack_format_to_base_format()

2015-06-16 Thread Anuj Phogat
Signed-off-by: Anuj Phogat 
---
 src/mesa/main/glformats.c | 44 
 src/mesa/main/glformats.h |  3 +++
 2 files changed, 47 insertions(+)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index ac69fab..cac243c 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1278,6 +1278,50 @@ _mesa_is_compressed_format(const struct gl_context *ctx, 
GLenum format)
}
 }
 
+/**
+ * Convert various unpack formats to the corresponding base format.
+ */
+GLenum
+_mesa_unpack_format_to_base_format(GLenum format)
+{
+   switch(format) {
+   case GL_RED_INTEGER:
+  return GL_RED;
+   case GL_GREEN_INTEGER:
+  return GL_GREEN;
+   case GL_BLUE_INTEGER:
+  return GL_BLUE;
+   case GL_RG_INTEGER:
+  return GL_RG;
+   case GL_RGB_INTEGER:
+  return GL_RGB;
+   case GL_RGBA_INTEGER:
+  return GL_RGBA;
+   case GL_BGR_INTEGER:
+  return GL_BGR;
+   case GL_BGRA_INTEGER:
+  return GL_BGRA;
+   case GL_ALPHA_INTEGER:
+  return GL_ALPHA;
+   case GL_LUMINANCE_INTEGER_EXT:
+  return GL_LUMINANCE;
+   case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+  return GL_LUMINANCE_ALPHA;
+   case GL_RED:
+   case GL_GREEN:
+   case GL_BLUE:
+   case GL_RG:
+   case GL_RGB:
+   case GL_RGBA:
+   case GL_BGR:
+   case GL_BGRA:
+   case GL_ALPHA:
+   case GL_LUMINANCE:
+   case GL_LUMINANCE_ALPHA:
+   default:
+  return format;
+   }
+}
 
 /**
  * Convert various base formats to the cooresponding integer format.
diff --git a/src/mesa/main/glformats.h b/src/mesa/main/glformats.h
index 8881cb7..419955a 100644
--- a/src/mesa/main/glformats.h
+++ b/src/mesa/main/glformats.h
@@ -101,6 +101,9 @@ _mesa_is_compressed_format(const struct gl_context *ctx, 
GLenum format);
 extern GLenum
 _mesa_base_format_to_integer_format(GLenum format);
 
+extern GLenum
+_mesa_unpack_format_to_base_format(GLenum format);
+
 extern GLboolean
 _mesa_base_format_has_channel(GLenum base_format, GLenum pname);
 
-- 
1.9.3

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


[Mesa-dev] [PATCH 03/14] mesa: Fix conditions to test signed, unsigned integer format

2015-06-16 Thread Anuj Phogat
Signed-off-by: Anuj Phogat 
Cc: 
---
 src/mesa/main/readpix.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index caa2648..a9416ef 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -160,10 +160,12 @@ _mesa_readpixels_needs_slow_path(const struct gl_context 
*ctx, GLenum format,
   srcType = _mesa_get_format_datatype(rb->Format);
 
   if ((srcType == GL_INT &&
+   _mesa_is_enum_format_integer(format) &&
(type == GL_UNSIGNED_INT ||
 type == GL_UNSIGNED_SHORT ||
 type == GL_UNSIGNED_BYTE)) ||
   (srcType == GL_UNSIGNED_INT &&
+   _mesa_is_enum_format_integer(format) &&
(type == GL_INT ||
 type == GL_SHORT ||
 type == GL_BYTE))) {
-- 
1.9.3

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


[Mesa-dev] [PATCH 13/14] mesa: Change the signature of _mesa_need_rgb_to_luminance_conversion()

2015-06-16 Thread Anuj Phogat
This allows us to handle cases when texImage->_BaseFormat doesn't match
_mesa_format_get_base_format(texImage->Format). _BaseFormat is what we
care about in this function.

Signed-off-by: Anuj Phogat 
---
 src/mesa/drivers/common/meta_tex_subimage.c |  4 +++-
 src/mesa/main/readpix.c | 28 +++-
 src/mesa/main/readpix.h |  3 ++-
 3 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/src/mesa/drivers/common/meta_tex_subimage.c 
b/src/mesa/drivers/common/meta_tex_subimage.c
index 6d52014..43e1210 100644
--- a/src/mesa/drivers/common/meta_tex_subimage.c
+++ b/src/mesa/drivers/common/meta_tex_subimage.c
@@ -262,6 +262,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
GLuint dims,
int full_height, image_height;
struct gl_texture_image *pbo_tex_image;
struct gl_renderbuffer *rb = NULL;
+   GLenum dstBaseFormat = _mesa_unpack_format_to_base_format(format);
GLenum status, base_format;
bool success = false, clear_channels_to_zero = false;
float save_clear_color[4];
@@ -284,7 +285,8 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
GLuint dims,
 type, GL_FALSE))
  return false;
 
-  if (_mesa_need_rgb_to_luminance_conversion(rb->Format, format))
+  if (_mesa_need_rgb_to_luminance_conversion(rb->_BaseFormat,
+ dstBaseFormat))
  return false;
 
   if (_mesa_need_signed_unsigned_int_conversion(rb->Format, format, type))
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index c98975f..3a9b766 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -47,17 +47,14 @@
  * Return true if the conversion L=R+G+B is needed.
  */
 GLboolean
-_mesa_need_rgb_to_luminance_conversion(mesa_format texFormat, GLenum format)
+_mesa_need_rgb_to_luminance_conversion(GLenum srcBaseFormat,
+   GLenum dstBaseFormat)
 {
-   GLenum baseTexFormat = _mesa_get_format_base_format(texFormat);
-
-   return (baseTexFormat == GL_RG ||
-   baseTexFormat == GL_RGB ||
-   baseTexFormat == GL_RGBA) &&
-  (format == GL_LUMINANCE ||
-   format == GL_LUMINANCE_ALPHA ||
-   format == GL_LUMINANCE_INTEGER_EXT ||
-   format == GL_LUMINANCE_ALPHA_INTEGER_EXT);
+   return (srcBaseFormat == GL_RG ||
+   srcBaseFormat == GL_RGB ||
+   srcBaseFormat == GL_RGBA) &&
+  (dstBaseFormat == GL_LUMINANCE ||
+   dstBaseFormat == GL_LUMINANCE_ALPHA);
 }
 
 /**
@@ -89,6 +86,8 @@ _mesa_get_readpixels_transfer_ops(const struct gl_context 
*ctx,
   GLboolean uses_blit)
 {
GLbitfield transferOps = ctx->_ImageTransferState;
+   GLenum srcBaseFormat = _mesa_get_format_base_format(texFormat);
+   GLenum dstBaseFormat = _mesa_unpack_format_to_base_format(format);
 
if (format == GL_DEPTH_COMPONENT ||
format == GL_DEPTH_STENCIL ||
@@ -125,7 +124,7 @@ _mesa_get_readpixels_transfer_ops(const struct gl_context 
*ctx,
 * have any effect anyway.
 */
if (_mesa_get_format_datatype(texFormat) == GL_UNSIGNED_NORMALIZED &&
-   !_mesa_need_rgb_to_luminance_conversion(texFormat, format)) {
+   !_mesa_need_rgb_to_luminance_conversion(srcBaseFormat, dstBaseFormat)) {
   transferOps &= ~IMAGE_CLAMP_BIT;
}
 
@@ -164,6 +163,7 @@ _mesa_readpixels_needs_slow_path(const struct gl_context 
*ctx, GLenum format,
 {
struct gl_renderbuffer *rb =
  _mesa_get_read_renderbuffer_for_format(ctx, format);
+   GLenum dstBaseFormat = _mesa_unpack_format_to_base_format(format);
 
assert(rb);
 
@@ -184,7 +184,8 @@ _mesa_readpixels_needs_slow_path(const struct gl_context 
*ctx, GLenum format,
 
default:
   /* Color formats. */
-  if (_mesa_need_rgb_to_luminance_conversion(rb->Format, format)) {
+  if (_mesa_need_rgb_to_luminance_conversion(rb->_BaseFormat,
+ dstBaseFormat)) {
  return GL_TRUE;
   }
 
@@ -458,6 +459,7 @@ read_rgba_pixels( struct gl_context *ctx,
uint8_t rebase_swizzle[4];
struct gl_framebuffer *fb = ctx->ReadBuffer;
struct gl_renderbuffer *rb = fb->_ColorReadBuffer;
+   GLenum dstBaseFormat = _mesa_unpack_format_to_base_format(format);
 
if (!rb)
   return;
@@ -469,7 +471,7 @@ read_rgba_pixels( struct gl_context *ctx,
dst_stride = _mesa_image_row_stride(packing, width, format, type);
dst_format = _mesa_format_from_format_and_type(format, type);
convert_rgb_to_lum =
-  _mesa_need_rgb_to_luminance_conversion(rb->Format, format);
+  _mesa_need_rgb_to_luminance_conversion(rb->_BaseFormat, dstBaseFormat);
dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
format, type, 0, 0);
 
diff --git a/src/mesa/main/readpix.h b/src/mesa/main/readpix.h
index b59decd..873b825 1006

[Mesa-dev] [PATCH 11/14] meta: Use _mesa_need_luminance_to_rgb_conversion() in decompress_texture_image()

2015-06-16 Thread Anuj Phogat
Signed-off-by: Anuj Phogat 
---
 src/mesa/drivers/common/meta.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index c9e58d8..6108d98 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -3132,16 +3132,8 @@ decompress_texture_image(struct gl_context *ctx,
* returned as red and two-channel texture values are returned as
* red/alpha.
*/
-  if (((baseTexFormat == GL_LUMINANCE ||
-baseTexFormat == GL_LUMINANCE_ALPHA ||
-baseTexFormat == GL_INTENSITY) &&
-   (destBaseFormat == GL_RGBA ||
-destBaseFormat == GL_RGB ||
-destBaseFormat == GL_RG ||
-destBaseFormat == GL_GREEN ||
-destBaseFormat == GL_BLUE ||
-destBaseFormat == GL_BGRA ||
-destBaseFormat == GL_BGR)) ||
+  if (_mesa_need_luminance_to_rgb_conversion(baseTexFormat,
+ destBaseFormat) ||
   /* If we're reading back an RGB(A) texture (using glGetTexImage) as
   * luminance then we need to return L=tex(R).
   */
-- 
1.9.3

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


[Mesa-dev] [PATCH 04/14] mesa: Add a mesa utility function _mesa_need_signed_unsigned_int_conversion()

2015-06-16 Thread Anuj Phogat
This utility function is used in a later patch.

Signed-off-by: Anuj Phogat 
Cc: 
---
 src/mesa/main/readpix.c | 32 ++--
 src/mesa/main/readpix.h |  4 
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index a9416ef..1038983 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -114,6 +114,22 @@ _mesa_get_readpixels_transfer_ops(const struct gl_context 
*ctx,
return transferOps;
 }
 
+bool
+_mesa_need_signed_unsigned_int_conversion(mesa_format rbFormat,
+  GLenum format, GLenum type)
+{
+  const GLenum srcType = _mesa_get_format_datatype(rbFormat);
+  return (srcType == GL_INT &&
+  _mesa_is_enum_format_integer(format) &&
+  (type == GL_UNSIGNED_INT ||
+   type == GL_UNSIGNED_SHORT ||
+   type == GL_UNSIGNED_BYTE)) ||
+ (srcType == GL_UNSIGNED_INT &&
+  _mesa_is_enum_format_integer(format) &&
+  (type == GL_INT ||
+   type == GL_SHORT ||
+   type == GL_BYTE));
+}
 
 /**
  * Return true if memcpy cannot be used for ReadPixels.
@@ -130,7 +146,6 @@ _mesa_readpixels_needs_slow_path(const struct gl_context 
*ctx, GLenum format,
 {
struct gl_renderbuffer *rb =
  _mesa_get_read_renderbuffer_for_format(ctx, format);
-   GLenum srcType;
 
assert(rb);
 
@@ -157,20 +172,9 @@ _mesa_readpixels_needs_slow_path(const struct gl_context 
*ctx, GLenum format,
 
   /* Conversion between signed and unsigned integers needs masking
* (it isn't just memcpy). */
-  srcType = _mesa_get_format_datatype(rb->Format);
-
-  if ((srcType == GL_INT &&
-   _mesa_is_enum_format_integer(format) &&
-   (type == GL_UNSIGNED_INT ||
-type == GL_UNSIGNED_SHORT ||
-type == GL_UNSIGNED_BYTE)) ||
-  (srcType == GL_UNSIGNED_INT &&
-   _mesa_is_enum_format_integer(format) &&
-   (type == GL_INT ||
-type == GL_SHORT ||
-type == GL_BYTE))) {
+  if (_mesa_need_signed_unsigned_int_conversion(rb->Format, format,
+ type))
  return GL_TRUE;
-  }
 
   /* And finally, see if there are any transfer ops. */
   return _mesa_get_readpixels_transfer_ops(ctx, rb->Format, format, type,
diff --git a/src/mesa/main/readpix.h b/src/mesa/main/readpix.h
index f894036..a93e263 100644
--- a/src/mesa/main/readpix.h
+++ b/src/mesa/main/readpix.h
@@ -46,6 +46,10 @@ _mesa_get_readpixels_transfer_ops(const struct gl_context 
*ctx,
   GLenum format, GLenum type,
   GLboolean uses_blit);
 
+extern bool
+_mesa_need_signed_unsigned_int_conversion(mesa_format rbFormat,
+  GLenum format, GLenum type);
+
 extern void
 _mesa_readpixels(struct gl_context *ctx,
  GLint x, GLint y, GLsizei width, GLsizei height,
-- 
1.9.3

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


[Mesa-dev] [PATCH 02/14] meta: Fix transfer operations check in meta pbo path for readpixels

2015-06-16 Thread Anuj Phogat
Without this patch, arb_color_buffer_float-readpixels test fails, when
forced to use meta pbo path.

Signed-off-by: Anuj Phogat 
Cc: 
---
 src/mesa/drivers/common/meta_tex_subimage.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/common/meta_tex_subimage.c 
b/src/mesa/drivers/common/meta_tex_subimage.c
index d2474f5..00364f8 100644
--- a/src/mesa/drivers/common/meta_tex_subimage.c
+++ b/src/mesa/drivers/common/meta_tex_subimage.c
@@ -273,12 +273,14 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
GLuint dims,
format == GL_COLOR_INDEX)
   return false;
 
-   if (ctx->_ImageTransferState)
-  return false;
-
-
+   /* Don't use meta path for readpixels in below conditions. */
if (!tex_image) {
   rb = ctx->ReadBuffer->_ColorReadBuffer;
+
+  if (_mesa_get_readpixels_transfer_ops(ctx, rb->Format, format,
+type, GL_FALSE))
+ return false;
+
   if (_mesa_need_rgb_to_luminance_conversion(rb->Format, format))
  return false;
}
-- 
1.9.3

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


Re: [Mesa-dev] [PATCH] configure.ac: rename LLVM_VERSION_PATCH to avoid conflict with llvm-config.h

2015-06-16 Thread Emil Velikov
On 13 June 2015 at 19:16, Marek Olšák  wrote:
> From: Marek Olšák 
>
> ---
>  configure.ac | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/configure.ac b/configure.ac
> index 34d1ac9..e6d947e 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1929,7 +1929,7 @@ if test "x$enable_gallium_llvm" = xyes; then
>  LLVM_COMPONENTS="${LLVM_COMPONENTS} all-targets ipo linker 
> instrumentation"
>  LLVM_COMPONENTS="${LLVM_COMPONENTS} irreader option objcarcopts 
> profiledata"
>  fi
> -DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT 
> -DLLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
> +DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT 
> -DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"

Silly questions:
If LLVM already sets LLVM_VERSION_PATCH shouldn't we be using it,
rather than setting our own ? Perhaps we can drop the define
altogether, considering that we're not using it ?

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


Re: [Mesa-dev] [PATCH 5/6] mesa: don't rebind constant buffers after every state change if GS is active

2015-06-16 Thread Emil Velikov
Hi Marek,

Out of curiosity:
Any rough idea of how much of a perf. improvement this might bring ?
Would the hardware ignore the newly (re)bound const. bufs, when the
values are unchanged ?

Thanks
Emil

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


Re: [Mesa-dev] [PATCH] configure.ac: rename LLVM_VERSION_PATCH to avoid conflict with llvm-config.h

2015-06-16 Thread Tom Stellard
On Tue, Jun 16, 2015 at 08:07:57PM +0100, Emil Velikov wrote:
> On 13 June 2015 at 19:16, Marek Olšák  wrote:
> > From: Marek Olšák 
> >
> > ---
> >  configure.ac | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index 34d1ac9..e6d947e 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -1929,7 +1929,7 @@ if test "x$enable_gallium_llvm" = xyes; then
> >  LLVM_COMPONENTS="${LLVM_COMPONENTS} all-targets ipo linker 
> > instrumentation"
> >  LLVM_COMPONENTS="${LLVM_COMPONENTS} irreader option 
> > objcarcopts profiledata"
> >  fi
> > -DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT 
> > -DLLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
> > +DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT 
> > -DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
> 
> Silly questions:
> If LLVM already sets LLVM_VERSION_PATCH shouldn't we be using it,
> rather than setting our own ? Perhaps we can drop the define
> altogether, considering that we're not using it ?
> 

Depending on the version of llvm and the build system that was used
LLVM_VERSION_PATH may or not be defined, so we can't rely on it.

-Tom

> Cheers,
> Emil
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [RFC shader-db] Add support for shadertoy tests

2015-06-16 Thread Rob Clark
Attached script grabs shaders from shadertoy, and dumps them out as
.shader_test files which can be run through shader-db for compiler
testing.

shadertoy only gives you a fragment shader (which works based on
gl_FragCoord), so a generic vertex shader is used.  And a blurb is
inserted for the pre-defined uniforms and main() function (which just
calls shadertoy mainImage() fxn).

---
TODO I guess we'd actually have to parse the shader to figure out if
the sampler uniforms were meant to be 2D/cube/etc.  Maybe we just
commit samplers we get from the script and massage them by hand?

PS. don't make fun of my py too much.. I'm a newb and figuring it
out as I go

 grab-shadertoy.py | 63 +++
 1 file changed, 63 insertions(+)
 create mode 100755 grab-shadertoy.py

diff --git a/grab-shadertoy.py b/grab-shadertoy.py
new file mode 100755
index 000..74e9d10
--- /dev/null
+++ b/grab-shadertoy.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python3
+
+
+import requests, json
+
+url = 'https://www.shadertoy.com/api/v1/shaders'
+key = '?key=NdnKw7'
+
+# Get the list of shaders
+r = requests.get(url + key)
+j = r.json()
+print('Found ' + str(j['Shaders']) + ' shaders')
+
+shader_ids = j['Results']
+for id in shader_ids:
+print('Fetching shader: ' + str(id))
+r = requests.get(url + '/' + id + key)
+j = r.json()
+s = j['Shader']
+info = s['info']
+print('Name: ' + info['name'])
+print('Description: ' + info['description'])
+i = 0;
+for p in s['renderpass']:
+fobj = open('shaders/shadertoy/' + str(id) + '_' + str(i) + 
'.shader_test', 'w')
+#print('Inputs: ' + str(p['inputs']))
+#print('Outputs: ' + str(p['outputs']))
+fobj.write('[require]\n')
+fobj.write('GLSL >= 1.30\n')
+fobj.write('\n');
+fobj.write('[fragment shader]\n')
+fobj.write('#version 130\n')
+# Shadertoy inserts some uniforms, so we need to do the same:
+fobj.write('uniform vec3  iResolution;\n');
+fobj.write('uniform float iGlobalTime;\n');
+fobj.write('uniform float iChannelTime[4];\n');
+fobj.write('uniform vec4  iMouse;\n');
+fobj.write('uniform vec4  iDate;\n');
+fobj.write('uniform float iSampleRate;\n');
+fobj.write('uniform vec3  iChannelResolution[4];\n');
+# TODO probably need to parse the shader to figure out if 
2d/cubemap/etc
+fobj.write('uniform sampler2D iChannel0;\n');
+fobj.write('uniform sampler2D iChannel1;\n');
+fobj.write('uniform sampler2D iChannel2;\n');
+fobj.write('uniform sampler2D iChannel3;\n');
+# Actual shadertoy shader body:
+fobj.write(p['code'])
+# Shadertoy shader uses mainImage(out vec4 fragColor, in vec2 
fragCoord)
+# so we need to insert a main:
+fobj.write('\nvoid main() { mainImage(gl_FragColor, gl_FragCoord.xy); 
}\n')
+fobj.write('\n\n')
+# And a generic vertex shader:
+fobj.write('[vertex shader]\n')
+fobj.write('#version 130\n')
+fobj.write('in vec2 position;\n')
+fobj.write('\n')
+fobj.write('void main()\n')
+fobj.write('{\n')
+fobj.write('   gl_Position = vec4(position, 0.0, 1.0);\n')
+fobj.write('}\n')
+
+fobj.close()
+i = 1 + i
-- 
2.4.2

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


Re: [Mesa-dev] [PATCH 5/6] mesa: don't rebind constant buffers after every state change if GS is active

2015-06-16 Thread Marek Olšák
There are probably 0 apps using GS, so the answer is 0.

The hardware doesn't ignore anything. It only does what it's told to do.

The radeonsi driver doesn't check if the state change is redundant or not.

Marek

On Tue, Jun 16, 2015 at 10:13 PM, Emil Velikov  wrote:
> Hi Marek,
>
> Out of curiosity:
> Any rough idea of how much of a perf. improvement this might bring ?
> Would the hardware ignore the newly (re)bound const. bufs, when the
> values are unchanged ?
>
> Thanks
> Emil
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 89819] WebGL Conformance swrast failure in conformance/uniforms/uniform-default-values.html

2015-06-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89819

Luke  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #8 from Luke  ---
Verified fixed by 6e5970ffee0129fb94d8b7f0ebd4fac3992e7dce in both Firefox and
Chrome.

Great detective work Roland. Thanks!

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] i965/cs: Setup push constant data for uniforms

2015-06-16 Thread Jordan Justen
brw_upload_cs_push_constants was based on gen6_upload_push_constants.

Signed-off-by: Jordan Justen 
---
 These 2 patches allow this piglit to pass:
 tests/spec/arb_compute_shader/execution/basic-uniform-access-atomic.shader_test
 (Also requires overriding the GL version and some extensions...)

 src/mesa/drivers/dri/i965/brw_context.h  |   2 +-
 src/mesa/drivers/dri/i965/brw_cs.cpp | 119 ++-
 src/mesa/drivers/dri/i965/brw_defines.h  |   6 ++
 src/mesa/drivers/dri/i965/brw_state.h|   1 +
 src/mesa/drivers/dri/i965/brw_state_upload.c |   2 +
 5 files changed, 125 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 01c4283..9ea0dfd 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1457,7 +1457,7 @@ struct brw_context
 
int num_atoms[BRW_NUM_PIPELINES];
const struct brw_tracked_state render_atoms[57];
-   const struct brw_tracked_state compute_atoms[3];
+   const struct brw_tracked_state compute_atoms[4];
 
/* If (INTEL_DEBUG & DEBUG_BATCH) */
struct {
diff --git a/src/mesa/drivers/dri/i965/brw_cs.cpp 
b/src/mesa/drivers/dri/i965/brw_cs.cpp
index 44c76ba..e26d576 100644
--- a/src/mesa/drivers/dri/i965/brw_cs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_cs.cpp
@@ -320,6 +320,9 @@ brw_upload_cs_state(struct brw_context *brw)
 
prog_data->binding_table.size_bytes,
 32, &stage_state->bind_bo_offset);
 
+   unsigned push_constant_size =
+  prog_data->nr_params * sizeof(gl_constant_value);
+   unsigned reg_aligned_constant_size = ALIGN(push_constant_size, 32);
unsigned threads = get_cs_thread_count(cs_prog_data);
 
uint32_t dwords = brw->gen < 8 ? 8 : 9;
@@ -352,12 +355,24 @@ brw_upload_cs_state(struct brw_context *brw)
 
OUT_BATCH(0);
const uint32_t vfe_urb_allocation = brw->gen >= 8 ? 2 : 0;
-   OUT_BATCH(SET_FIELD(vfe_urb_allocation, MEDIA_VFE_STATE_URB_ALLOC));
+   const uint32_t vfe_curbe_allocation =
+  (reg_aligned_constant_size / 32) * threads + 32;
+   OUT_BATCH(SET_FIELD(vfe_urb_allocation, MEDIA_VFE_STATE_URB_ALLOC) |
+ SET_FIELD(vfe_curbe_allocation, MEDIA_VFE_STATE_CURBE_ALLOC));
OUT_BATCH(0);
OUT_BATCH(0);
OUT_BATCH(0);
ADVANCE_BATCH();
 
+   if (reg_aligned_constant_size > 0) {
+  BEGIN_BATCH(4);
+  OUT_BATCH(MEDIA_CURBE_LOAD << 16 | (4 - 2));
+  OUT_BATCH(0);
+  OUT_BATCH(reg_aligned_constant_size * threads);
+  OUT_BATCH(stage_state->push_const_offset);
+  ADVANCE_BATCH();
+   }
+
/* BRW_NEW_SURFACES and BRW_NEW_*_CONSTBUF */
memcpy(bind, stage_state->surf_offset,
   prog_data->binding_table.size_bytes);
@@ -371,7 +386,8 @@ brw_upload_cs_state(struct brw_context *brw)
desc[dw++] = 0;
desc[dw++] = 0;
desc[dw++] = stage_state->bind_bo_offset;
-   desc[dw++] = 0;
+   desc[dw++] = SET_FIELD((reg_aligned_constant_size / 32) + 0,
+  MEDIA_CURBE_READ_LENGTH);
const uint32_t media_threads =
   brw->gen >= 8 ?
   SET_FIELD(threads, GEN8_MEDIA_GPGPU_THREAD_COUNT) :
@@ -392,8 +408,103 @@ const struct brw_tracked_state brw_cs_state = {
/* explicit initialisers aren't valid C++, comment
 * them for documentation purposes */
/* .dirty = */{
-  /* .mesa = */ 0,
-  /* .brw = */  BRW_NEW_CS_PROG_DATA,
+  /* .mesa = */ _NEW_PROGRAM_CONSTANTS,
+  /* .brw = */  BRW_NEW_CS_PROG_DATA |
+BRW_NEW_PUSH_CONSTANT_ALLOCATION,
},
/* .emit = */ brw_upload_cs_state
 };
+
+
+/**
+ * Creates a region containing the push constants for the CS on gen7+.
+ *
+ * Push constants are constant values (such as GLSL uniforms) that are
+ * pre-loaded into a shader stage's register space at thread spawn time.
+ *
+ * Not all GLSL uniforms will be uploaded as push constants: The hardware has
+ * a limitation of 32 or 64 EU registers (256 or 512 floats) per stage to be
+ * uploaded as push constants, while GL 4.4 requires at least 1024 components
+ * to be usable for the VS.  Plus, currently we always use pull constants
+ * instead of push constants when doing variable-index array access.
+ *
+ * For other stages, see brw_curbe.c for the equivalent gen4/5 code and
+ * gen6_vs_state.c for gen6+.
+ */
+static void
+brw_upload_cs_push_constants(struct brw_context *brw,
+ const struct gl_program *prog,
+ const struct brw_cs_prog_data *cs_prog_data,
+ struct brw_stage_state *stage_state,
+ enum aub_state_struct_type type)
+{
+   struct gl_context *ctx = &brw->ctx;
+   const struct brw_stage_prog_data *prog_data =
+  (brw_stage_prog_data*) cs_prog_data;
+
+   /* Updates the ParamaterValues[i] pointers for all parameters of the
+* basic type of PROGRAM_STATE_VAR.
+ 

[Mesa-dev] [PATCH 2/2] main/state: Flag new constants for compute shaders

2015-06-16 Thread Jordan Justen
Signed-off-by: Jordan Justen 
---
 src/mesa/main/state.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index bede7fe..beb2721 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -278,6 +278,16 @@ update_program_constants(struct gl_context *ctx)
   }
}
 
+   if (ctx->ComputeProgram._Current) {
+  const struct gl_program_parameter_list *params =
+ ctx->ComputeProgram._Current->Base.Parameters;
+  /*FIXME: StateFlags is always 0 because we have unnamed constant
+   *   not state changes */
+  if (params /*&& params->StateFlags & ctx->NewState*/) {
+ new_state |= _NEW_PROGRAM_CONSTANTS;
+  }
+   }
+
return new_state;
 }
 
-- 
2.1.4

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


[Mesa-dev] [PATCH] i965/compute: Fix undefined code with right_mask for SIMD32

2015-06-16 Thread Jordan Justen
Although we don't support SIMD32, krh pointed out that the left shift
by 32 is undefined by C/C++ for 32-bit integers.

Suggested-by: Kristian Høgsberg 
Signed-off-by: Jordan Justen 
Cc: Kristian Høgsberg 
---
 src/mesa/drivers/dri/i965/brw_compute.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_compute.c 
b/src/mesa/drivers/dri/i965/brw_compute.c
index b3d6de5..5693ab5 100644
--- a/src/mesa/drivers/dri/i965/brw_compute.c
+++ b/src/mesa/drivers/dri/i965/brw_compute.c
@@ -45,7 +45,7 @@ brw_emit_gpgpu_walker(struct brw_context *brw, const GLuint 
*num_groups)
unsigned thread_width_max =
   (group_size + simd_size - 1) / simd_size;
 
-   uint32_t right_mask = (1u << simd_size) - 1;
+   uint32_t right_mask = 0xu >> (32 - simd_size);
const unsigned right_non_aligned = group_size & (simd_size - 1);
if (right_non_aligned != 0)
   right_mask >>= (simd_size - right_non_aligned);
-- 
2.1.4

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


Re: [Mesa-dev] [PATCH 2/2] main/state: Flag new constants for compute shaders

2015-06-16 Thread Marek Olšák
One question: Why?

I just removed the same code for GS:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=42a3c1ec8471fc76eb6d3d6f1bd1739e24a5f33a

Marek

On Tue, Jun 16, 2015 at 11:21 PM, Jordan Justen
 wrote:
> Signed-off-by: Jordan Justen 
> ---
>  src/mesa/main/state.c | 10 ++
>  1 file changed, 10 insertions(+)
>
> diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
> index bede7fe..beb2721 100644
> --- a/src/mesa/main/state.c
> +++ b/src/mesa/main/state.c
> @@ -278,6 +278,16 @@ update_program_constants(struct gl_context *ctx)
>}
> }
>
> +   if (ctx->ComputeProgram._Current) {
> +  const struct gl_program_parameter_list *params =
> + ctx->ComputeProgram._Current->Base.Parameters;
> +  /*FIXME: StateFlags is always 0 because we have unnamed constant
> +   *   not state changes */
> +  if (params /*&& params->StateFlags & ctx->NewState*/) {
> + new_state |= _NEW_PROGRAM_CONSTANTS;
> +  }
> +   }
> +
> return new_state;
>  }
>
> --
> 2.1.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] What branch to get patch 47790

2015-06-16 Thread Meng, David
Hi:
I am new to this email list.  I would like to get a help from you.

I found a patch with number of 47790 which supports Intel Broadwell(BDW) system 
gen8 GPU.  The author is Topi Pohjolainen.  The description is in below.
I need this patch to launch a virtual machine on BDW system in which we are 
using Mesa library in user space.  But I could not find this patch in mesa 
master or any branches.  Would you please pint me where I can find a branch 
including this patch? 

I highly appreciate any help.

Regards,

David
patch title and 
description-
[Mesa-dev] i965: Don't use gl-context for fbo-blits
This series introduces new blorp parameter type for blit programs
compiled from glsl-sources. For most parts the launch logic just
calls core i965 batch emission logic.
Vertex batches are handcrafted containing full vertex header
information. This is needed because the pipeline is programmed to
skip vertex shader, clip and viewport transformation in strips&fans
(SF) but to provide the vertices directly from vertex fetcher (VF)
to the windower (WM).

Topi Pohjolainen (14):
  i965/blorp/gen7: Support for loading glsl-based fragment shaders
  i965/blorp/gen6: Support for loading glsl-based fragment shaders
  meta: Provide read access to blit shaders
  i965/meta: Add helper for looking up blit programs
  i965/blorp: Add plumbing for glsl-based color blits
  i965/blorp: Add support for loading vertices for glsl-based blits
  i965/blorp: Add support for setting up surfaces for glsl-based blits
  i965/blorp: Add support for setting samplers for glsl-based blits
  i965/gen6: Add support for setting minimum layer for tex surfaces
  i965/blorp: Enable glsl-based fbo blits
  i965/blorp/gen7: Prepare re-using for gen8
  i965/blorp/gen7: Expose state setup applicable to gen8
  i965/blorp/gen6: Prepare vertex buffer setup logic for gen8
  i965/blorp/gen8: Execution support

 src/mesa/drivers/common/meta.c   |  17 +-
 src/mesa/drivers/common/meta.h   |   5 +-
 src/mesa/drivers/dri/i965/Makefile.sources   |   1 +
 src/mesa/drivers/dri/i965/brw_blorp.cpp  |  21 +-
 src/mesa/drivers/dri/i965/brw_blorp.h| 127 ++
 src/mesa/drivers/dri/i965/brw_blorp_blit.cpp |  90 +
 src/mesa/drivers/dri/i965/brw_context.h  |  10 +
 src/mesa/drivers/dri/i965/brw_meta_util.c| 148 +++
 src/mesa/drivers/dri/i965/brw_meta_util.h|   9 +
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |   5 +-
 src/mesa/drivers/dri/i965/gen6_blorp.cpp | 280 -
 src/mesa/drivers/dri/i965/gen7_blorp.cpp |  87 +++-
 src/mesa/drivers/dri/i965/gen8_blorp.cpp | 494 +++
 src/mesa/drivers/dri/i965/intel_fbo.c|  11 +
 14 files changed, 1273 insertions(+), 32 deletions(-)
 create mode 100644 src/mesa/drivers/dri/i965/gen8_blorp.cpp

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


Re: [Mesa-dev] [PATCH v2 15/82] mesa: Initialize and free shader storage buffers

2015-06-16 Thread Jordan Justen
On 2015-06-03 00:01:05, Iago Toral Quiroga wrote:
> ---
>  src/mesa/main/bufferobj.c | 19 +++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index c5d4ada..a528787 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -836,6 +836,9 @@ _mesa_init_buffer_objects( struct gl_context *ctx )
> _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer,
>  ctx->Shared->NullBufferObj);
>  
> +   _mesa_reference_buffer_object(ctx, &ctx->ShaderStorageBuffer,
> +ctx->Shared->NullBufferObj);

Tabs here?

With that fixed, this and
14/82 glsl: fix error messages in invalid declarations of shader storage blocks

Reviewed-by: Jordan Justen 

> _mesa_reference_buffer_object(ctx, &ctx->AtomicBuffer,
>  ctx->Shared->NullBufferObj);
>  
> @@ -850,6 +853,14 @@ _mesa_init_buffer_objects( struct gl_context *ctx )
>ctx->UniformBufferBindings[i].Size = -1;
> }
>  
> +   for (i = 0; i < MAX_COMBINED_SHADER_STORAGE_BUFFERS; i++) {
> +  _mesa_reference_buffer_object(ctx,
> +
> &ctx->ShaderStorageBufferBindings[i].BufferObject,
> +ctx->Shared->NullBufferObj);
> +  ctx->ShaderStorageBufferBindings[i].Offset = -1;
> +  ctx->ShaderStorageBufferBindings[i].Size = -1;
> +   }
> +
> for (i = 0; i < MAX_COMBINED_ATOMIC_BUFFERS; i++) {
>_mesa_reference_buffer_object(ctx,
> 
> &ctx->AtomicBufferBindings[i].BufferObject,
> @@ -872,6 +883,8 @@ _mesa_free_buffer_objects( struct gl_context *ctx )
>  
> _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, NULL);
>  
> +   _mesa_reference_buffer_object(ctx, &ctx->ShaderStorageBuffer, NULL);
> +
> _mesa_reference_buffer_object(ctx, &ctx->AtomicBuffer, NULL);
>  
> _mesa_reference_buffer_object(ctx, &ctx->DrawIndirectBuffer, NULL);
> @@ -882,6 +895,12 @@ _mesa_free_buffer_objects( struct gl_context *ctx )
> NULL);
> }
>  
> +   for (i = 0; i < MAX_COMBINED_SHADER_STORAGE_BUFFERS; i++) {
> +  _mesa_reference_buffer_object(ctx,
> +
> &ctx->ShaderStorageBufferBindings[i].BufferObject,
> +NULL);
> +   }
> +
> for (i = 0; i < MAX_COMBINED_ATOMIC_BUFFERS; i++) {
>_mesa_reference_buffer_object(ctx,
> 
> &ctx->AtomicBufferBindings[i].BufferObject,
> -- 
> 1.9.1
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] What branch to get patch 47790

2015-06-16 Thread Anuj Phogat
Adding Topi to Cc.

On Tue, Jun 16, 2015 at 3:08 PM, Meng, David  wrote:
> Hi:
> I am new to this email list.  I would like to get a help from you.
>
> I found a patch with number of 47790 which supports Intel Broadwell(BDW) 
> system gen8 GPU.  The author is Topi Pohjolainen.  The description is in 
> below.
> I need this patch to launch a virtual machine on BDW system in which we are 
> using Mesa library in user space.  But I could not find this patch in mesa 
> master or any branches.  Would you please pint me where I can find a branch 
> including this patch?
>
> I highly appreciate any help.
>
> Regards,
>
> David
> patch title and 
> description-
> [Mesa-dev] i965: Don't use gl-context for fbo-blits
> This series introduces new blorp parameter type for blit programs
> compiled from glsl-sources. For most parts the launch logic just
> calls core i965 batch emission logic.
> Vertex batches are handcrafted containing full vertex header
> information. This is needed because the pipeline is programmed to
> skip vertex shader, clip and viewport transformation in strips&fans
> (SF) but to provide the vertices directly from vertex fetcher (VF)
> to the windower (WM).
>
> Topi Pohjolainen (14):
>   i965/blorp/gen7: Support for loading glsl-based fragment shaders
>   i965/blorp/gen6: Support for loading glsl-based fragment shaders
>   meta: Provide read access to blit shaders
>   i965/meta: Add helper for looking up blit programs
>   i965/blorp: Add plumbing for glsl-based color blits
>   i965/blorp: Add support for loading vertices for glsl-based blits
>   i965/blorp: Add support for setting up surfaces for glsl-based blits
>   i965/blorp: Add support for setting samplers for glsl-based blits
>   i965/gen6: Add support for setting minimum layer for tex surfaces
>   i965/blorp: Enable glsl-based fbo blits
>   i965/blorp/gen7: Prepare re-using for gen8
>   i965/blorp/gen7: Expose state setup applicable to gen8
>   i965/blorp/gen6: Prepare vertex buffer setup logic for gen8
>   i965/blorp/gen8: Execution support
>
>  src/mesa/drivers/common/meta.c   |  17 +-
>  src/mesa/drivers/common/meta.h   |   5 +-
>  src/mesa/drivers/dri/i965/Makefile.sources   |   1 +
>  src/mesa/drivers/dri/i965/brw_blorp.cpp  |  21 +-
>  src/mesa/drivers/dri/i965/brw_blorp.h| 127 ++
>  src/mesa/drivers/dri/i965/brw_blorp_blit.cpp |  90 +
>  src/mesa/drivers/dri/i965/brw_context.h  |  10 +
>  src/mesa/drivers/dri/i965/brw_meta_util.c| 148 +++
>  src/mesa/drivers/dri/i965/brw_meta_util.h|   9 +
>  src/mesa/drivers/dri/i965/brw_wm_surface_state.c |   5 +-
>  src/mesa/drivers/dri/i965/gen6_blorp.cpp | 280 -
>  src/mesa/drivers/dri/i965/gen7_blorp.cpp |  87 +++-
>  src/mesa/drivers/dri/i965/gen8_blorp.cpp | 494 
> +++
>  src/mesa/drivers/dri/i965/intel_fbo.c|  11 +
>  14 files changed, 1273 insertions(+), 32 deletions(-)
>  create mode 100644 src/mesa/drivers/dri/i965/gen8_blorp.cpp
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 89818] WebGL Conformance conformance/textures/texture-size-limit.html -> OUT_OF_MEMORY

2015-06-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89818

Luke  changed:

   What|Removed |Added

 CC||srol...@vmware.com

--- Comment #1 from Luke  ---
The test passes by forcing softpipe with:
$ export LIBGL_ALWAYS_SOFTWARE=1
$ export DRAW_USE_LLVM=0
$ export GALLIUM_DRIVER=softpipe

So for swrast, this is llvmpipe specific. Adding Roland to the case.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] What branch to get patch 47790

2015-06-16 Thread Meng, David
Thank you Anuj.


-Original Message-
From: Anuj Phogat [mailto:anuj.pho...@gmail.com] 
Sent: Tuesday, June 16, 2015 3:35 PM
To: Meng, David
Cc: mesa-dev@lists.freedesktop.org; Pohjolainen, Topi
Subject: Re: [Mesa-dev] What branch to get patch 47790

Adding Topi to Cc.

On Tue, Jun 16, 2015 at 3:08 PM, Meng, David  wrote:
> Hi:
> I am new to this email list.  I would like to get a help from you.
>
> I found a patch with number of 47790 which supports Intel Broadwell(BDW) 
> system gen8 GPU.  The author is Topi Pohjolainen.  The description is in 
> below.
> I need this patch to launch a virtual machine on BDW system in which we are 
> using Mesa library in user space.  But I could not find this patch in mesa 
> master or any branches.  Would you please pint me where I can find a branch 
> including this patch?
>
> I highly appreciate any help.
>
> Regards,
>
> David
> patch title and 
> description-
> [Mesa-dev] i965: Don't use gl-context for fbo-blits This series 
> introduces new blorp parameter type for blit programs compiled from 
> glsl-sources. For most parts the launch logic just calls core i965 
> batch emission logic.
> Vertex batches are handcrafted containing full vertex header 
> information. This is needed because the pipeline is programmed to skip 
> vertex shader, clip and viewport transformation in strips&fans
> (SF) but to provide the vertices directly from vertex fetcher (VF) to 
> the windower (WM).
>
> Topi Pohjolainen (14):
>   i965/blorp/gen7: Support for loading glsl-based fragment shaders
>   i965/blorp/gen6: Support for loading glsl-based fragment shaders
>   meta: Provide read access to blit shaders
>   i965/meta: Add helper for looking up blit programs
>   i965/blorp: Add plumbing for glsl-based color blits
>   i965/blorp: Add support for loading vertices for glsl-based blits
>   i965/blorp: Add support for setting up surfaces for glsl-based blits
>   i965/blorp: Add support for setting samplers for glsl-based blits
>   i965/gen6: Add support for setting minimum layer for tex surfaces
>   i965/blorp: Enable glsl-based fbo blits
>   i965/blorp/gen7: Prepare re-using for gen8
>   i965/blorp/gen7: Expose state setup applicable to gen8
>   i965/blorp/gen6: Prepare vertex buffer setup logic for gen8
>   i965/blorp/gen8: Execution support
>
>  src/mesa/drivers/common/meta.c   |  17 +-
>  src/mesa/drivers/common/meta.h   |   5 +-
>  src/mesa/drivers/dri/i965/Makefile.sources   |   1 +
>  src/mesa/drivers/dri/i965/brw_blorp.cpp  |  21 +-
>  src/mesa/drivers/dri/i965/brw_blorp.h| 127 ++
>  src/mesa/drivers/dri/i965/brw_blorp_blit.cpp |  90 +
>  src/mesa/drivers/dri/i965/brw_context.h  |  10 +
>  src/mesa/drivers/dri/i965/brw_meta_util.c| 148 +++
>  src/mesa/drivers/dri/i965/brw_meta_util.h|   9 +
>  src/mesa/drivers/dri/i965/brw_wm_surface_state.c |   5 +-
>  src/mesa/drivers/dri/i965/gen6_blorp.cpp | 280 -
>  src/mesa/drivers/dri/i965/gen7_blorp.cpp |  87 +++-
>  src/mesa/drivers/dri/i965/gen8_blorp.cpp | 494 
> +++
>  src/mesa/drivers/dri/i965/intel_fbo.c|  11 +
>  14 files changed, 1273 insertions(+), 32 deletions(-)  create mode 
> 100644 src/mesa/drivers/dri/i965/gen8_blorp.cpp
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965/skl: Fix aligning mt->total_width to the block size

2015-06-16 Thread Anuj Phogat
On Tue, Jun 16, 2015 at 5:53 AM, Neil Roberts  wrote:
> brw_miptree_layout_2d tries to ensure that mt->total_width is a
> multiple of the compressed block size, presumably because it wouldn't
> be possible to make an image that has a fraction of a block. However
> it was doing this by aligning mt->total_width to align_w. Previously
> align_w has been used as a shortcut for getting the block width
> because before Gen9 the block width was always equal to the alignment.
> Commit 4ab8d59a2 tried to fix these cases to use the block width
> instead of the alignment but it missed this case.
>
> I think in practice this probably won't make any difference because
> the buffer for the texture will be allocated to be large enough to
> contain the entire pitch and libdrm aligns the pitch to the tile width
> anyway. However I think the patch is worth having to make the
> intention clearer.
> ---
>  src/mesa/drivers/dri/i965/brw_tex_layout.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c 
> b/src/mesa/drivers/dri/i965/brw_tex_layout.c
> index 1e7d8a1..dbb6cef 100644
> --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c
> +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c
> @@ -366,9 +366,8 @@ brw_miptree_layout_2d(struct intel_mipmap_tree *mt)
>
> mt->total_width = mt->physical_width0;
>
> -   if (mt->compressed) {
> -   mt->total_width = ALIGN(mt->physical_width0, mt->align_w);
> -   }
> +   if (mt->compressed)
> +   mt->total_width = ALIGN(mt->total_width, bw);
>
> /* May need to adjust width to accommodate the placement of
>  * the 2nd mipmap.  This occurs when the alignment
> --
> 1.9.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reviewed-by: Anuj Phogat 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] What branch to get patch 47790

2015-06-16 Thread Kenneth Graunke
On Tuesday, June 16, 2015 10:08:38 PM Meng, David wrote:
> Hi:
> I am new to this email list.  I would like to get a help from you.
> 
> I found a patch with number of 47790 which supports Intel Broadwell(BDW) 
> system gen8 GPU.  The author is Topi Pohjolainen.  The description is in 
> below.
> I need this patch to launch a virtual machine on BDW system in which we are 
> using Mesa library in user space.  But I could not find this patch in mesa 
> master or any branches.  Would you please pint me where I can find a branch 
> including this patch? 
> 
> I highly appreciate any help.
> 
> Regards,
> 
> David
> patch title and 
> description-
> [Mesa-dev] i965: Don't use gl-context for fbo-blits
> This series introduces new blorp parameter type for blit programs
> compiled from glsl-sources. For most parts the launch logic just
> calls core i965 batch emission logic.
> Vertex batches are handcrafted containing full vertex header
> information. This is needed because the pipeline is programmed to
> skip vertex shader, clip and viewport transformation in strips&fans
> (SF) but to provide the vertices directly from vertex fetcher (VF)
> to the windower (WM).
> 
> Topi Pohjolainen (14):
>   i965/blorp/gen7: Support for loading glsl-based fragment shaders
>   i965/blorp/gen6: Support for loading glsl-based fragment shaders
>   meta: Provide read access to blit shaders
>   i965/meta: Add helper for looking up blit programs
>   i965/blorp: Add plumbing for glsl-based color blits
>   i965/blorp: Add support for loading vertices for glsl-based blits
>   i965/blorp: Add support for setting up surfaces for glsl-based blits
>   i965/blorp: Add support for setting samplers for glsl-based blits
>   i965/gen6: Add support for setting minimum layer for tex surfaces
>   i965/blorp: Enable glsl-based fbo blits
>   i965/blorp/gen7: Prepare re-using for gen8
>   i965/blorp/gen7: Expose state setup applicable to gen8
>   i965/blorp/gen6: Prepare vertex buffer setup logic for gen8
>   i965/blorp/gen8: Execution support

Hi David,

I'm not sure what you mean by "patch with a number of 47790".  We don't
number patches in the Mesa community.  That must be some Intel internal
number.

Those patches optimize our implementation of glBlitFramebuffer() on
Broadwell, which should provide better performance in some cases.  We
haven't landed them yet because Topi is rewriting them.

Those patches are not required for Broadwell support, however.
Broadwell has been supported since Mesa 10.1 (but you should use a more
recent version, such as 10.6).

I don't know what's required for virtual machines, as I've never tried
that.  But these patches definitely aren't relevant.

--Ken


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


Re: [Mesa-dev] [PATCH] i965/compute: Fix undefined code with right_mask for SIMD32

2015-06-16 Thread Kenneth Graunke
On Tuesday, June 16, 2015 02:46:22 PM Jordan Justen wrote:
> Although we don't support SIMD32, krh pointed out that the left shift
> by 32 is undefined by C/C++ for 32-bit integers.
> 
> Suggested-by: Kristian Høgsberg 
> Signed-off-by: Jordan Justen 
> Cc: Kristian Høgsberg 
> ---
>  src/mesa/drivers/dri/i965/brw_compute.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_compute.c 
> b/src/mesa/drivers/dri/i965/brw_compute.c
> index b3d6de5..5693ab5 100644
> --- a/src/mesa/drivers/dri/i965/brw_compute.c
> +++ b/src/mesa/drivers/dri/i965/brw_compute.c
> @@ -45,7 +45,7 @@ brw_emit_gpgpu_walker(struct brw_context *brw, const GLuint 
> *num_groups)
> unsigned thread_width_max =
>(group_size + simd_size - 1) / simd_size;
>  
> -   uint32_t right_mask = (1u << simd_size) - 1;
> +   uint32_t right_mask = 0xu >> (32 - simd_size);
> const unsigned right_non_aligned = group_size & (simd_size - 1);
> if (right_non_aligned != 0)
>right_mask >>= (simd_size - right_non_aligned);
> 

Patch works as advertised:

python>> hex((1 << 8) - 1)
'0xff'
python>> hex((1 << 16) - 1)
'0x'
python>> hex((1 << 32) - 1)
'0x'
python>> hex(0x >> (32 - 8))
'0xff'
python>> hex(0x >> (32 - 16))
'0x'
python>> hex(0x >> (32 - 32))
'0x'

Reviewed-by: Kenneth Graunke 


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


[Mesa-dev] [PATCHES] Tessellation is here

2015-06-16 Thread Marek Olšák
Hi,

First, I'd like to thank Fabian Bieler, Chris Forbes, and Ilia Mirkin
for their contributions to this.

The development of tessellation has reached the point that the only
way to make it better and more compliant is to write piglit tests that
help find small bugs that are difficult to catch during code review.
According to piglit, it's already more compliant than the NVIDIA
driver. (The NVIDIA GLSL compiler sometimes even dies with an internal
error on some of the variable indexing tests. I haven't tested
Catalyst.)

Other than piglit, the following apps have been tested:
- Unigine Heaven 4.0 (wireframe both on and off)
- TessMark 0.3.0 *
- GpuTest 0.7.0 containing a newer version of TessMark *
- Tutorials 30 and 31 from http://ogldev.atspace.co.uk/ *

(* These don't work with the OpenGL Core profile and need overrides
and code hacks to enable OpenGL 4.0 Compatibility)

The RadeonSI driver support is complete and requires LLVM 3.6.2. There
is just one small bug with GpuTest 0.7.0.

The patches will be split up into 3 series:
1) Mesa + GLSL
2) State tracker
3) Radeonsi

 docs/GL3.txt  |   2 +-
 docs/relnotes/10.7.0.html |   1 +
 src/gallium/docs/source/screen.rst|   4 +
 src/gallium/drivers/freedreno/freedreno_screen.c  |   1 +
 src/gallium/drivers/i915/i915_screen.c|   1 +
 src/gallium/drivers/ilo/ilo_screen.c  |   1 +
 src/gallium/drivers/llvmpipe/lp_screen.c  |   1 +
 src/gallium/drivers/nouveau/nv30/nv30_screen.c|   1 +
 src/gallium/drivers/nouveau/nv50/nv50_screen.c|   1 +
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c|   1 +
 src/gallium/drivers/r300/r300_screen.c|   1 +
 src/gallium/drivers/r600/r600_pipe.c  |   1 +
 src/gallium/drivers/radeon/r600_pipe_common.c |   6 +
 src/gallium/drivers/radeon/r600_pipe_common.h |  20 +-
 src/gallium/drivers/radeon/radeon_llvm.h  |  14 +-
 src/gallium/drivers/radeon/radeon_llvm_emit.c |   2 +
 .../drivers/radeon/radeon_setup_tgsi_llvm.c   |  40 +-
 src/gallium/drivers/radeonsi/si_blit.c|   2 +
 src/gallium/drivers/radeonsi/si_descriptors.c | 251 --
 src/gallium/drivers/radeonsi/si_hw_context.c  |   8 +
 src/gallium/drivers/radeonsi/si_pipe.c|  22 +-
 src/gallium/drivers/radeonsi/si_pipe.h|  29 +-
 src/gallium/drivers/radeonsi/si_shader.c  | 835 ++--
 src/gallium/drivers/radeonsi/si_shader.h  | 123 ++-
 src/gallium/drivers/radeonsi/si_state.c   |  47 +-
 src/gallium/drivers/radeonsi/si_state.h   |  23 +-
 src/gallium/drivers/radeonsi/si_state_draw.c  | 217 -
 src/gallium/drivers/radeonsi/si_state_shaders.c   | 494 +++-
 src/gallium/drivers/softpipe/sp_screen.c  |   1 +
 src/gallium/drivers/svga/svga_screen.c|   1 +
 src/gallium/drivers/vc4/vc4_screen.c  |   1 +
 src/gallium/include/pipe/p_defines.h  |   1 +
 src/glsl/Makefile.sources |   1 +
 src/glsl/ast.h|  55 +-
 src/glsl/ast_array_index.cpp  |  47 +-
 src/glsl/ast_to_hir.cpp   | 350 +++-
 src/glsl/ast_type.cpp | 115 ++-
 src/glsl/builtin_functions.cpp|   4 +-
 src/glsl/builtin_variables.cpp| 112 ++-
 src/glsl/glcpp/glcpp-parse.y  |   3 +
 src/glsl/glsl_lexer.ll|   5 +-
 src/glsl/glsl_parser.yy   | 133 +++-
 src/glsl/glsl_parser_extras.cpp   |  60 +-
 src/glsl/glsl_parser_extras.h |  48 +-
 src/glsl/glsl_types.cpp   |   5 +
 src/glsl/glsl_types.h |   6 +
 src/glsl/ir.cpp   |   2 +
 src/glsl/ir.h |   1 +
 src/glsl/ir_optimization.h|   8 +-
 src/glsl/ir_print_visitor.cpp |   5 +-
 src/glsl/ir_reader.cpp|   2 +
 src/glsl/ir_set_program_inouts.cpp|  96 ++-
 src/glsl/link_interface_blocks.cpp|  11 +-
 src/glsl/link_varyings.cpp| 183 -
 src/glsl/link_varyings.h  |  16 +-
 src/glsl/linker.cpp   | 415 +-
 src/glsl/lower_clip_distance.cpp  | 185 +++--
 src/glsl/lower_named_interface_blocks.cpp |   8 +-
 src/glsl/lower_output_reads.cpp   |  13 +-
 src/glsl/lower_packed_varyings.cpp|   1 +
 src/glsl/lower_tess_level.cpp | 462 +++
 src/glsl/lower_variable_index_to_cond_assign.cpp  |  43 +-
 src/glsl/main.cpp |   8 +-
 src/glsl/shader_enums.h   |  21 +-
 src/glsl/standalone_scaf

[Mesa-dev] [PATCH 10/46] mesa: take tessellation into account when validating GS input primitive mode

2015-06-16 Thread Marek Olšák
From: Marek Olšák 

I've reported the bug in the Khronos bugzilla.
---
 src/mesa/main/api_validate.c | 22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 3871765..401120a 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -174,11 +174,29 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum 
mode, const char *name)
 *   TRIANGLES_ADJACENCY_ARB and  is not
 *   TRIANGLES_ADJACENCY_ARB or TRIANGLE_STRIP_ADJACENCY_ARB.
 *
+* The GL spec doesn't mention any interaction with tessellation, which
+* is clearly a spec bug. The same rule should apply, but instead of
+* the draw primitive mode, the tessellation evaluation shader primitive
+* mode should be used for the checking.
*/
if (ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]) {
   const GLenum geom_mode =
  ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]->Geom.InputType;
-  switch (mode) {
+  struct gl_shader_program *tes =
+ ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
+  GLenum mode_before_gs = mode;
+
+  if (tes) {
+ if (tes->TessEval.PointMode)
+mode_before_gs = GL_POINTS;
+ else if (tes->TessEval.PrimitiveMode == GL_ISOLINES)
+mode_before_gs = GL_LINES;
+ else
+/* the GL_QUADS mode generates triangles too */
+mode_before_gs = GL_TRIANGLES;
+  }
+
+  switch (mode_before_gs) {
   case GL_POINTS:
  valid_enum = (geom_mode == GL_POINTS);
  break;
@@ -213,7 +231,7 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, 
const char *name)
  _mesa_error(ctx, GL_INVALID_OPERATION,
  "%s(mode=%s vs geometry shader input %s)",
  name,
- _mesa_lookup_prim_by_nr(mode),
+ _mesa_lookup_prim_by_nr(mode_before_gs),
  _mesa_lookup_prim_by_nr(geom_mode));
  return GL_FALSE;
   }
-- 
2.1.0

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


[Mesa-dev] [PATCH 07/46] mesa: add misc tessellation shader support

2015-06-16 Thread Marek Olšák
From: Fabian Bieler 

---
 src/mesa/program/program.c | 27 
 src/mesa/program/program.h | 62 +-
 2 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
index ffad395..2d03bba 100644
--- a/src/mesa/program/program.c
+++ b/src/mesa/program/program.c
@@ -365,6 +365,16 @@ _mesa_new_program(struct gl_context *ctx, GLenum target, 
GLuint id)
  CALLOC_STRUCT(gl_geometry_program),
  target, id);
   break;
+   case GL_TESS_CONTROL_PROGRAM_NV:
+  prog = _mesa_init_tess_ctrl_program(ctx,
+  CALLOC_STRUCT(gl_tess_ctrl_program),
+  target, id);
+  break;
+   case GL_TESS_EVALUATION_PROGRAM_NV:
+  prog = _mesa_init_tess_eval_program(ctx,
+ CALLOC_STRUCT(gl_tess_eval_program),
+ target, id);
+  break;
case GL_COMPUTE_PROGRAM_NV:
   prog = _mesa_init_compute_program(ctx,
 CALLOC_STRUCT(gl_compute_program),
@@ -586,6 +596,23 @@ _mesa_clone_program(struct gl_context *ctx, const struct 
gl_program *prog)
  gpc->UsesStreams = gp->UsesStreams;
   }
   break;
+   case GL_TESS_CONTROL_PROGRAM_NV:
+  {
+ const struct gl_tess_ctrl_program *tcp = 
gl_tess_ctrl_program_const(prog);
+ struct gl_tess_ctrl_program *tcpc = gl_tess_ctrl_program(clone);
+ tcpc->VerticesOut = tcp->VerticesOut;
+  }
+  break;
+   case GL_TESS_EVALUATION_PROGRAM_NV:
+  {
+ const struct gl_tess_eval_program *tep = 
gl_tess_eval_program_const(prog);
+ struct gl_tess_eval_program *tepc = gl_tess_eval_program(clone);
+ tepc->PrimitiveMode = tep->PrimitiveMode;
+ tepc->Spacing = tep->Spacing;
+ tepc->VertexOrder = tep->VertexOrder;
+ tepc->PointMode = tep->PointMode;
+  }
+  break;
default:
   _mesa_problem(NULL, "Unexpected target in _mesa_clone_program");
}
diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
index eafb969..a894147 100644
--- a/src/mesa/program/program.h
+++ b/src/mesa/program/program.h
@@ -157,6 +157,25 @@ _mesa_reference_compprog(struct gl_context *ctx,
(struct gl_program *) prog);
 }
 
+
+static inline void
+_mesa_reference_tesscprog(struct gl_context *ctx,
+ struct gl_tess_ctrl_program **ptr,
+ struct gl_tess_ctrl_program *prog)
+{
+   _mesa_reference_program(ctx, (struct gl_program **) ptr,
+   (struct gl_program *) prog);
+}
+
+static inline void
+_mesa_reference_tesseprog(struct gl_context *ctx,
+ struct gl_tess_eval_program **ptr,
+ struct gl_tess_eval_program *prog)
+{
+   _mesa_reference_program(ctx, (struct gl_program **) ptr,
+   (struct gl_program *) prog);
+}
+
 extern struct gl_program *
 _mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog);
 
@@ -167,6 +186,20 @@ _mesa_clone_vertex_program(struct gl_context *ctx,
return (struct gl_vertex_program *) _mesa_clone_program(ctx, &prog->Base);
 }
 
+static inline struct gl_tess_ctrl_program *
+_mesa_clone_tess_ctrl_program(struct gl_context *ctx,
+ const struct gl_tess_ctrl_program *prog)
+{
+   return (struct gl_tess_ctrl_program *) _mesa_clone_program(ctx, 
&prog->Base);
+}
+
+static inline struct gl_tess_eval_program *
+_mesa_clone_tess_eval_program(struct gl_context *ctx,
+ const struct gl_tess_eval_program *prog)
+{
+   return (struct gl_tess_eval_program *) _mesa_clone_program(ctx, 
&prog->Base);
+}
+
 static inline struct gl_geometry_program *
 _mesa_clone_geometry_program(struct gl_context *ctx,
  const struct gl_geometry_program *prog)
@@ -262,7 +295,9 @@ _mesa_shader_stage_to_program(unsigned stage)
 }
 
 
-/* Cast wrappers from gl_program to gl_vertex/geometry/fragment_program */
+/* Cast wrappers from gl_program to derived program types.
+ * (e.g. gl_vertex_program)
+ */
 
 static inline struct gl_fragment_program *
 gl_fragment_program(struct gl_program *prog)
@@ -315,6 +350,31 @@ gl_compute_program_const(const struct gl_program *prog)
return (const struct gl_compute_program *) prog;
 }
 
+static inline struct gl_tess_ctrl_program *
+gl_tess_ctrl_program(struct gl_program *prog)
+{
+   return (struct gl_tess_ctrl_program *) prog;
+}
+
+static inline const struct gl_tess_ctrl_program *
+gl_tess_ctrl_program_const(const struct gl_program *prog)
+{
+   return (const struct gl_tess_ctrl_program *) prog;
+}
+
+
+static inline struct gl_tess_eval_program *
+gl_tess_eval_program(struct gl_program *prog)
+{
+   return (struct gl_tess_e

[Mesa-dev] [PATCH 09/46] mesa: allow drawing of patch primitives

2015-06-16 Thread Marek Olšák
From: Chris Forbes 

Cosmetic changes and fixes by Marek.
---
 src/mesa/main/api_validate.c | 45 
 1 file changed, 45 insertions(+)

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 9c2e29e..3871765 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -127,6 +127,9 @@ _mesa_is_valid_prim_mode(struct gl_context *ctx, GLenum 
mode)
if (mode <= GL_TRIANGLE_STRIP_ADJACENCY)
   return _mesa_has_geometry_shaders(ctx);
 
+   if (mode == GL_PATCHES)
+  return _mesa_has_tessellation(ctx);
+
return false;
 }
 
@@ -136,6 +139,7 @@ _mesa_is_valid_prim_mode(struct gl_context *ctx, GLenum 
mode)
  * etc?  Also, do additional checking related to transformation feedback.
  * Note: this function cannot be called during glNewList(GL_COMPILE) because
  * this code depends on current transform feedback state.
+ * Also, do additional checking related to tessellation shaders.
  */
 GLboolean
 _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
@@ -215,6 +219,36 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, 
const char *name)
   }
}
 
+   /* From the OpenGL 4.0 (Core Profile) spec (section 2.12):
+*
+* "Tessellation operates only on patch primitives. If tessellation is
+*  active, any command that transfers vertices to the GL will
+*  generate an INVALID_OPERATION error if the primitive mode is not
+*  PATCHES.
+*  Patch primitives are not supported by pipeline stages below the
+*  tessellation evaluation shader. If there is no active program
+*  object or the active program object does not contain a tessellation
+*  evaluation shader, the error INVALID_OPERATION is generated by any
+*  command that transfers vertices to the GL if the primitive mode is
+*  PATCHES."
+*
+*/
+   if (ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL] ||
+   ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL]) {
+  if (mode != GL_PATCHES) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "only GL_PATCHES valid with tessellation");
+ return GL_FALSE;
+  }
+   }
+   else {
+  if (mode == GL_PATCHES) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "GL_PATCHES only valid with tessellation");
+ return GL_FALSE;
+  }
+   }
+
/* From the GL_EXT_transform_feedback spec:
 *
 * "The error INVALID_OPERATION is generated if Begin, or any command
@@ -247,6 +281,17 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, 
const char *name)
 pass = GL_FALSE;
  }
   }
+  else if (ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]) {
+ struct gl_shader_program *tes =
+ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
+
+ if (tes->TessEval.PointMode)
+pass = ctx->TransformFeedback.Mode == GL_POINTS;
+ else if (tes->TessEval.PrimitiveMode == GL_ISOLINES)
+pass = ctx->TransformFeedback.Mode == GL_LINES;
+ else
+pass = ctx->TransformFeedback.Mode == GL_TRIANGLES;
+  }
   else {
  switch (mode) {
  case GL_POINTS:
-- 
2.1.0

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


[Mesa-dev] [PATCH 02/46] mapi: add ARB_tessellation_shader

2015-06-16 Thread Marek Olšák
From: Fabian Bieler 

---
 src/mapi/glapi/gen/ARB_tessellation_shader.xml | 62 ++
 src/mapi/glapi/gen/gl_API.xml  |  6 ++-
 src/mapi/glapi/gen/gl_enums.py |  1 +
 src/mesa/main/mtypes.h |  2 +-
 src/mesa/main/shaderapi.c  | 18 
 src/mesa/main/shaderapi.h  |  8 
 src/mesa/main/tests/dispatch_sanity.cpp|  2 +
 7 files changed, 97 insertions(+), 2 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_tessellation_shader.xml

diff --git a/src/mapi/glapi/gen/ARB_tessellation_shader.xml 
b/src/mapi/glapi/gen/ARB_tessellation_shader.xml
new file mode 100644
index 000..16a2139
--- /dev/null
+++ b/src/mapi/glapi/gen/ARB_tessellation_shader.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index bd8db62..f75fd66 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -8072,7 +8072,11 @@
 
 http://www.w3.org/2001/XInclude"/>
 
-
+
+
+http://www.w3.org/2001/XInclude"/>
+
+
 
 http://www.w3.org/2001/XInclude"/>
 
diff --git a/src/mapi/glapi/gen/gl_enums.py b/src/mapi/glapi/gen/gl_enums.py
index 955f27d..dfda774 100644
--- a/src/mapi/glapi/gen/gl_enums.py
+++ b/src/mapi/glapi/gen/gl_enums.py
@@ -118,6 +118,7 @@ static const char *prim_names[PRIM_MAX+3] = {
"GL_LINE_STRIP_ADJACENCY",
"GL_TRIANGLES_ADJACENCY",
"GL_TRIANGLE_STRIP_ADJACENCY",
+   "GL_PATCHES",
"outside begin/end",
"unknown state"
 };
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 205c7d2..086f553 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -90,7 +90,7 @@ struct vbo_context;
 
 
 /** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */
-#define PRIM_MAX GL_TRIANGLE_STRIP_ADJACENCY
+#define PRIM_MAX GL_PATCHES
 #define PRIM_OUTSIDE_BEGIN_END   (PRIM_MAX + 1)
 #define PRIM_UNKNOWN (PRIM_MAX + 2)
 
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index a4296ad..ea7917e 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1984,3 +1984,21 @@ _mesa_CreateShaderProgramv(GLenum type, GLsizei count,
 
return _mesa_create_shader_program(ctx, GL_TRUE, type, count, strings);
 }
+
+
+/**
+ * For GL_ARB_tessellation_shader
+ */
+extern void GLAPIENTRY
+_mesa_PatchParameteri(GLenum pname, GLint value)
+{
+   /* STUB */
+}
+
+
+extern void GLAPIENTRY
+_mesa_PatchParameterfv(GLenum pname, const GLfloat *values)
+{
+   /* STUB */
+}
+
diff --git a/src/mesa/main/shaderapi.h b/src/mesa/main/shaderapi.h
index aba6d5d..90e2e2d 100644
--- a/src/mesa/main/shaderapi.h
+++ b/src/mesa/main/shaderapi.h
@@ -264,6 +264,14 @@ _mesa_get_program_resourceiv(struct gl_shader_program 
*shProg,
  GLsizei bufSize, GLsizei *length,
  GLint *params);
 
+/* GL_ARB_tessellation_shader */
+extern void GLAPIENTRY
+_mesa_PatchParameteri(GLenum pname, GLint value);
+
+extern void GLAPIENTRY
+_mesa_PatchParameterfv(GLenum pname, const GLfloat *values);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 0b7262a..cc521ed 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -563,6 +563,8 @@ const struct function common_desktop_functions_possible[] = 
{
 
/* GL 4.0 */
{ "glMinSampleShading", 40, -1 },
+   { "glPatchParameteri", 40, -1 },
+   { "glPatchParameterfv", 40, -1 },
{ "glBlendEquationi", 40, -1 },
{ "glBlendEquationSeparatei", 40, -1 },
{ "glBlendFunci", 40, -1 },
-- 
2.1.0

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


[Mesa-dev] [PATCH 03/46] mesa: add tessellation shader structs

2015-06-16 Thread Marek Olšák
From: Fabian Bieler 

Marek: remove unused members, cleanup
---
 src/mesa/main/mtypes.h | 105 +
 1 file changed, 105 insertions(+)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 086f553..12789f1 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2163,6 +2163,29 @@ struct gl_vertex_program
 };
 
 
+/** Tessellation control program object */
+struct gl_tess_ctrl_program
+{
+   struct gl_program Base;   /**< base class */
+
+   /* output layout */
+   GLint VerticesOut;
+};
+
+
+/** Tessellation evaluation program object */
+struct gl_tess_eval_program
+{
+   struct gl_program Base;   /**< base class */
+
+   /* input layout */
+   GLenum PrimitiveMode; /* GL_TRIANGLES, GL_QUADS or GL_ISOLINES */
+   GLenum Spacing;   /* GL_EQUAL, GL_FRACTIONAL_EVEN, GL_FRACTIONAL_ODD */
+   GLenum VertexOrder;   /* GL_CW or GL_CCW */
+   bool PointMode;
+};
+
+
 /** Geometry program object */
 struct gl_geometry_program
 {
@@ -2265,6 +2288,27 @@ struct gl_vertex_program_state
GLboolean _Overriden;
 };
 
+/**
+ * Context state for tessellation control programs.
+ */
+struct gl_tess_ctrl_program_state
+{
+   /** Currently bound and valid shader. */
+   struct gl_tess_ctrl_program *_Current;
+
+   GLint patch_vertices;
+   GLfloat patch_default_outer_level[4];
+   GLfloat patch_default_inner_level[2];
+};
+
+/**
+ * Context state for tessellation evaluation programs.
+ */
+struct gl_tess_eval_program_state
+{
+   /** Currently bound and valid shader. */
+   struct gl_tess_eval_program *_Current;
+};
 
 /**
  * Context state for geometry programs.
@@ -2445,6 +2489,41 @@ struct gl_shader
bool pixel_center_integer;
 
/**
+* Tessellation Control shader state from layout qualifiers.
+*/
+   struct {
+  /**
+   * 0 - vertices not declared in shader, or
+   * 1 .. GL_MAX_PATCH_VERTICES
+   */
+  GLint VerticesOut;
+   } TessCtrl;
+
+   /**
+* Tessellation Evaluation shader state from layout qualifiers.
+*/
+   struct {
+  /**
+   * GL_TRIANGLES, GL_QUADS, GL_ISOLINES or PRIM_UNKNOWN if it's not set
+   * in this shader.
+   */
+  GLenum PrimitiveMode;
+  /**
+   * GL_EQUAL, GL_FRACTIONAL_ODD, GL_FRACTIONAL_EVEN, or 0 if it's not set
+   * in this shader.
+   */
+  GLenum Spacing;
+  /**
+   * GL_CW, GL_CCW, or 0 if it's not set in this shader.
+   */
+  GLenum VertexOrder;
+  /**
+   * 1, 0, or -1 if it's not set in this shader.
+   */
+  int PointMode;
+   } TessEval;
+
+   /**
 * Geometry shader state from GLSL 1.50 layout qualifiers.
 */
struct {
@@ -2668,6 +2747,30 @@ struct gl_shader_program
enum gl_frag_depth_layout FragDepthLayout;
 
/**
+* Tessellation Control shader state from layout qualifiers.
+*/
+   struct {
+  /**
+   * 0 - vertices not declared in shader, or
+   * 1 .. GL_MAX_PATCH_VERTICES
+   */
+  GLint VerticesOut;
+   } TessCtrl;
+
+   /**
+* Tessellation Evaluation shader state from layout qualifiers.
+*/
+   struct {
+  /** GL_TRIANGLES, GL_QUADS or GL_ISOLINES */
+  GLenum PrimitiveMode;
+  /** GL_EQUAL, GL_FRACTIONAL_ODD or GL_FRACTIONAL_EVEN */
+  GLenum Spacing;
+  /** GL_CW or GL_CCW */
+  GLenum VertexOrder;
+  bool PointMode;
+   } TessEval;
+
+   /**
 * Geometry shader state - copied into gl_geometry_program by
 * _mesa_copy_linked_program_data().
 */
@@ -4201,6 +4304,8 @@ struct gl_context
struct gl_fragment_program_state FragmentProgram;
struct gl_geometry_program_state GeometryProgram;
struct gl_compute_program_state ComputeProgram;
+   struct gl_tess_ctrl_program_state TessCtrlProgram;
+   struct gl_tess_eval_program_state TessEvalProgram;
struct gl_ati_fragment_shader_state ATIFragmentShader;
 
struct gl_pipeline_shader_state Pipeline; /**< GLSL pipeline shader object 
state */
-- 
2.1.0

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


[Mesa-dev] [PATCH 05/46] mesa: add tessellation shader state and limits

2015-06-16 Thread Marek Olšák
From: Chris Forbes 

---
 src/mesa/main/config.h| 8 
 src/mesa/main/context.c   | 8 
 src/mesa/main/mtypes.h| 6 ++
 src/mesa/main/shaderapi.c | 7 +++
 4 files changed, 29 insertions(+)

diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index 9c3baf4..833d8c0 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -294,6 +294,14 @@
 /** For GL_ARB_pipeline_statistics_query */
 #define MAX_PIPELINE_STATISTICS 11
 
+/** For GL_ARB_tessellation_shader */
+/*@{*/
+#define MAX_TESS_GEN_LEVEL 64
+#define MAX_PATCH_VERTICES 32
+#define MAX_TESS_PATCH_COMPONENTS 120
+#define MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 4096
+/*@}*/
+
 /*
  * Color channel component order
  * 
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 4875f47..c86800a 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -726,6 +726,14 @@ _mesa_init_constants(struct gl_constants *consts, gl_api 
api)
 
/** GL_KHR_context_flush_control */
consts->ContextReleaseBehavior = GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH;
+
+   /** GL_ARB_tessellation_shader */
+   consts->MaxTessGenLevel = MAX_TESS_GEN_LEVEL;
+   consts->MaxPatchVertices = MAX_PATCH_VERTICES;
+   consts->Program[MESA_SHADER_TESS_CTRL].MaxTextureImageUnits = 
MAX_TEXTURE_IMAGE_UNITS;
+   consts->Program[MESA_SHADER_TESS_EVAL].MaxTextureImageUnits = 
MAX_TEXTURE_IMAGE_UNITS;
+   consts->MaxTessPatchComponents = MAX_TESS_PATCH_COMPONENTS;
+   consts->MaxTessControlTotalOutputComponents = 
MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS;
 }
 
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 12789f1..07a4b97 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3681,6 +3681,12 @@ struct gl_constants
GLenum ContextReleaseBehavior;
 
struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
+
+   /** GL_ARB_tessellation_shader */
+   GLuint MaxPatchVertices;
+   GLuint MaxTessGenLevel;
+   GLuint MaxTessPatchComponents;
+   GLuint MaxTessControlTotalOutputComponents;
 };
 
 
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index ea7917e..a247250 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -110,6 +110,7 @@ _mesa_init_shader_state(struct gl_context *ctx)
 */
struct gl_shader_compiler_options options;
gl_shader_stage sh;
+   int i;
 
memset(&options, 0, sizeof(options));
options.MaxUnrollIterations = 32;
@@ -126,6 +127,12 @@ _mesa_init_shader_state(struct gl_context *ctx)
/* Extended for ARB_separate_shader_objects */
ctx->Shader.RefCount = 1;
mtx_init(&ctx->Shader.Mutex, mtx_plain);
+
+   ctx->TessCtrlProgram.patch_vertices = 3;
+   for (i = 0; i < 4; ++i)
+  ctx->TessCtrlProgram.patch_default_outer_level[i] = 1.0;
+   for (i = 0; i < 2; ++i)
+  ctx->TessCtrlProgram.patch_default_inner_level[i] = 1.0;
 }
 
 
-- 
2.1.0

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


[Mesa-dev] [PATCH 33/46] glsl: restrict indexing for writes to TCS outputs to gl_InvocationID

2015-06-16 Thread Marek Olšák
From: Chris Forbes 

Marek: handle ir_swizzle
---
 src/glsl/ast_to_hir.cpp | 69 +
 1 file changed, 58 insertions(+), 11 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index fb957a1..7ffe169 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -640,6 +640,34 @@ shift_result_type(const struct glsl_type *type_a,
 }
 
 /**
+ * Returns the innermost array index expression in an rvalue tree.
+ * This is the largest indexing level -- if an array of blocks, then
+ * it is the block index rather than an indexing expression for an
+ * array-typed member of an array of blocks.
+ */
+static ir_rvalue *
+find_innermost_array_index(ir_rvalue *rv)
+{
+   ir_dereference_array *last = NULL;
+   while (rv) {
+  if (rv->as_dereference_array()) {
+ last = rv->as_dereference_array();
+ rv = last->array;
+  } else if (rv->as_dereference_record())
+ rv = rv->as_dereference_record()->record;
+  else if (rv->as_swizzle())
+ rv = rv->as_swizzle()->val;
+  else
+ rv = NULL;
+   }
+
+   if (last)
+  return last->array_index;
+
+   return NULL;
+}
+
+/**
  * Validates that a value can be assigned to a location with a specified type
  *
  * Validates that \c rhs can be assigned to some location.  If the types are
@@ -655,9 +683,9 @@ shift_result_type(const struct glsl_type *type_a,
  * In addition to being used for assignments, this function is used to
  * type-check return values.
  */
-ir_rvalue *
+static ir_rvalue *
 validate_assignment(struct _mesa_glsl_parse_state *state,
-YYLTYPE loc, const glsl_type *lhs_type,
+YYLTYPE loc, ir_rvalue *lhs,
 ir_rvalue *rhs, bool is_initializer)
 {
/* If there is already some error in the RHS, just return it.  Anything
@@ -666,9 +694,28 @@ validate_assignment(struct _mesa_glsl_parse_state *state,
if (rhs->type->is_error())
   return rhs;
 
+   /* In the Tessellation Control Shader:
+* If a per-vertex output variable is used as an l-value, it is an error
+* if the expression indicating the vertex number is not the identifier
+* `gl_InvocationID`.
+*/
+   if (state->stage == MESA_SHADER_TESS_CTRL) {
+  ir_variable *var = lhs->variable_referenced();
+  if (var->data.mode == ir_var_shader_out && !var->data.patch) {
+ ir_rvalue *index = find_innermost_array_index(lhs);
+ ir_variable *index_var = index ? index->variable_referenced() : NULL;
+ if (!index_var || strcmp(index_var->name, "gl_InvocationID") != 0) {
+_mesa_glsl_error(&loc, state,
+ "Tessellation control shader outputs can only "
+ "be indexed by gl_InvocationID");
+return NULL;
+ }
+  }
+   }
+
/* If the types are identical, the assignment can trivially proceed.
 */
-   if (rhs->type == lhs_type)
+   if (rhs->type == lhs->type)
   return rhs;
 
/* If the array element types are the same and the LHS is unsized,
@@ -678,8 +725,8 @@ validate_assignment(struct _mesa_glsl_parse_state *state,
 * Note: Whole-array assignments are not permitted in GLSL 1.10, but this
 * is handled by ir_dereference::is_lvalue.
 */
-   if (lhs_type->is_unsized_array() && rhs->type->is_array()
-   && (lhs_type->fields.array == rhs->type->fields.array)) {
+   if (lhs->type->is_unsized_array() && rhs->type->is_array()
+   && (lhs->type->fields.array == rhs->type->fields.array)) {
   if (is_initializer) {
  return rhs;
   } else {
@@ -690,8 +737,8 @@ validate_assignment(struct _mesa_glsl_parse_state *state,
}
 
/* Check for implicit conversion in GLSL 1.20 */
-   if (apply_implicit_conversion(lhs_type, rhs, state)) {
-  if (rhs->type == lhs_type)
+   if (apply_implicit_conversion(lhs->type, rhs, state)) {
+  if (rhs->type == lhs->type)
 return rhs;
}
 
@@ -699,7 +746,7 @@ validate_assignment(struct _mesa_glsl_parse_state *state,
 "%s of type %s cannot be assigned to "
 "variable of type %s",
 is_initializer ? "initializer" : "value",
-rhs->type->name, lhs_type->name);
+rhs->type->name, lhs->type->name);
 
return NULL;
 }
@@ -734,7 +781,7 @@ do_assignment(exec_list *instructions, struct 
_mesa_glsl_parse_state *state,
 
   if (unlikely(lhs_expr->operation == ir_binop_vector_extract)) {
  ir_rvalue *new_rhs =
-validate_assignment(state, lhs_loc, lhs->type,
+validate_assignment(state, lhs_loc, lhs,
 rhs, is_initializer);
 
  if (new_rhs == NULL) {
@@ -796,7 +843,7 @@ do_assignment(exec_list *instructions, struct 
_mesa_glsl_parse_state *state,
}
 
ir_rvalue *new_rhs =
-  validate_assignment(state, lhs_loc, lhs->type, rhs, is_initializer);
+  va

[Mesa-dev] [PATCH 23/46] glsl: allow linking of tessellation shaders.

2015-06-16 Thread Marek Olšák
From: Chris Forbes 

Marek: require a tess eval shader if a tess control shader is present
---
 src/glsl/link_interface_blocks.cpp |  11 +-
 src/glsl/link_varyings.cpp |  10 +-
 src/glsl/linker.cpp| 280 -
 3 files changed, 294 insertions(+), 7 deletions(-)

diff --git a/src/glsl/link_interface_blocks.cpp 
b/src/glsl/link_interface_blocks.cpp
index 07f5b42..dbcff4f 100644
--- a/src/glsl/link_interface_blocks.cpp
+++ b/src/glsl/link_interface_blocks.cpp
@@ -133,9 +133,9 @@ intrastage_match(interface_block_definition *a,
  * Check if two interfaces match, according to interstage (in/out) interface
  * matching rules.
  *
- * If \c extra_array_level is true, then vertex-to-geometry shader matching
- * rules are enforced (i.e. a successful match requires the consumer interface
- * to be an array and the producer interface to be a non-array).
+ * If \c extra_array_level is true, the consumer interface is required to be
+ * an array and the producer interface is required to be a non-array.
+ * This is used for tessellation control and geometry shader consumers.
  */
 bool
 interstage_match(const interface_block_definition *producer,
@@ -313,7 +313,10 @@ validate_interstage_inout_blocks(struct gl_shader_program 
*prog,
  const gl_shader *consumer)
 {
interface_block_definitions definitions;
-   const bool extra_array_level = consumer->Stage == MESA_SHADER_GEOMETRY;
+   /* VS -> GS, VS -> TCS, VS -> TES, TES -> GS */
+   const bool extra_array_level = (producer->Stage == MESA_SHADER_VERTEX &&
+   consumer->Stage != MESA_SHADER_FRAGMENT) ||
+  consumer->Stage == MESA_SHADER_GEOMETRY;
 
/* Add input interfaces from the consumer to the symbol table. */
foreach_in_list(ir_instruction, node, consumer->ir) {
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index c8f1bb9..373d337 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -54,10 +54,16 @@ cross_validate_types_and_qualifiers(struct 
gl_shader_program *prog,
/* Check that the types match between stages.
 */
const glsl_type *type_to_match = input->type;
-   if (consumer_stage == MESA_SHADER_GEOMETRY) {
-  assert(type_to_match->is_array()); /* Enforced by ast_to_hir */
+
+   /* VS -> GS, VS -> TCS, VS -> TES, TES -> GS */
+   const bool extra_array_level = (producer_stage == MESA_SHADER_VERTEX &&
+   consumer_stage != MESA_SHADER_FRAGMENT) ||
+  consumer_stage == MESA_SHADER_GEOMETRY;
+   if (extra_array_level) {
+  assert(type_to_match->is_array());
   type_to_match = type_to_match->fields.array;
}
+
if (type_to_match != output->type) {
   /* There is a bit of a special case for gl_TexCoord.  This
* built-in is unsized by default.  Applications that variable
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 9978380..49a88b9 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -250,6 +250,53 @@ public:
}
 };
 
+class tess_eval_array_resize_visitor : public ir_hierarchical_visitor {
+public:
+   unsigned num_vertices;
+   gl_shader_program *prog;
+
+   tess_eval_array_resize_visitor(unsigned num_vertices, gl_shader_program 
*prog)
+   {
+  this->num_vertices = num_vertices;
+  this->prog = prog;
+   }
+
+   virtual ~tess_eval_array_resize_visitor()
+   {
+  /* empty */
+   }
+
+   virtual ir_visitor_status visit(ir_variable *var)
+   {
+  if (!var->type->is_array() || var->data.mode != ir_var_shader_in || 
var->data.patch)
+ return visit_continue;
+
+  var->type = glsl_type::get_array_instance(var->type->fields.array,
+this->num_vertices);
+  var->data.max_array_access = this->num_vertices - 1;
+
+  return visit_continue;
+   }
+
+   /* Dereferences of input variables need to be updated so that their type
+* matches the newly assigned type of the variable they are accessing. */
+   virtual ir_visitor_status visit(ir_dereference_variable *ir)
+   {
+  ir->type = ir->var->type;
+  return visit_continue;
+   }
+
+   /* Dereferences of 2D input arrays need to be updated so that their type
+* matches the newly assigned type of the array they are accessing. */
+   virtual ir_visitor_status visit_leave(ir_dereference_array *ir)
+   {
+  const glsl_type *const vt = ir->array->type;
+  if (vt->is_array())
+ ir->type = vt->fields.array;
+  return visit_continue;
+   }
+};
+
 /**
  * Visitor that determines the highest stream id to which a (geometry) shader
  * emits vertices. It also checks whether End{Stream}Primitive is ever called.
@@ -1350,6 +1397,167 @@ private:
hash_table *unnamed_interfaces;
 };
 
+
+/**
+ * Performs the cross-validation of tessellation control shader vertices and
+ * layout qualifiers for the a

[Mesa-dev] [PATCH 36/46] glsl: push vertex count determination down one level

2015-06-16 Thread Marek Olšák
From: Chris Forbes 

We have the prog here, so we don't need the caller to work this out for
us.
---
 src/glsl/link_varyings.cpp | 12 ++--
 src/glsl/link_varyings.h   |  3 +--
 src/glsl/linker.cpp| 13 -
 3 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index d439b62..2f7d19b 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -1346,9 +1346,6 @@ canonicalize_shader_io(exec_list *ir, enum 
ir_variable_mode io_mode)
  *each of these objects that matches one of the outputs of the
  *producer.
  *
- * \param gs_input_vertices: if \c consumer is a geometry shader, this is the
- *number of input vertices it accepts.  Otherwise zero.
- *
  * When num_tfeedback_decls is nonzero, it is permissible for the consumer to
  * be NULL.  In this case, varying locations are assigned solely based on the
  * requirements of transform feedback.
@@ -1359,8 +1356,7 @@ assign_varying_locations(struct gl_context *ctx,
 struct gl_shader_program *prog,
 gl_shader *producer, gl_shader *consumer,
  unsigned num_tfeedback_decls,
- tfeedback_decl *tfeedback_decls,
- unsigned gs_input_vertices)
+ tfeedback_decl *tfeedback_decls)
 {
varying_matches matches(ctx->Const.DisableVaryingPacking,
consumer && consumer->Stage == 
MESA_SHADER_FRAGMENT);
@@ -1374,6 +1370,10 @@ assign_varying_locations(struct gl_context *ctx,
   NULL,
};
 
+   unsigned consumer_vertices = 0;
+   if (consumer && consumer->Stage == MESA_SHADER_GEOMETRY)
+  consumer_vertices = prog->Geom.VerticesIn;
+
/* Operate in a total of four passes.
 *
 * 1. Sort inputs / outputs into a canonical order.  This is necessary so
@@ -1513,7 +1513,7 @@ assign_varying_locations(struct gl_context *ctx,
   }
   if (consumer) {
  lower_packed_varyings(mem_ctx, slots_used, ir_var_shader_in,
-   gs_input_vertices, consumer);
+   consumer_vertices, consumer);
   }
}
 
diff --git a/src/glsl/link_varyings.h b/src/glsl/link_varyings.h
index e0d57ce..024c81d 100644
--- a/src/glsl/link_varyings.h
+++ b/src/glsl/link_varyings.h
@@ -255,8 +255,7 @@ assign_varying_locations(struct gl_context *ctx,
 struct gl_shader_program *prog,
 gl_shader *producer, gl_shader *consumer,
  unsigned num_tfeedback_decls,
- tfeedback_decl *tfeedback_decls,
- unsigned gs_input_vertices);
+ tfeedback_decl *tfeedback_decls);
 
 bool
 check_against_output_limit(struct gl_context *ctx,
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index acf6f81..5ee84fc 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -3314,8 +3314,7 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
   */
  if (!assign_varying_locations(ctx, mem_ctx, prog,
NULL, prog->_LinkedShaders[first],
-   num_tfeedback_decls, tfeedback_decls,
-   prog->Geom.VerticesIn))
+   num_tfeedback_decls, tfeedback_decls))
 goto done;
   }
 
@@ -3326,8 +3325,7 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
   */
  if (!assign_varying_locations(ctx, mem_ctx, prog,
sh, NULL,
-   num_tfeedback_decls, tfeedback_decls,
-   0))
+   num_tfeedback_decls, tfeedback_decls))
 goto done;
   }
 
@@ -3355,8 +3353,7 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
NULL /* producer */,
sh /* consumer */,
0 /* num_tfeedback_decls */,
-   NULL /* tfeedback_decls */,
-   0 /* gs_input_vertices */))
+   NULL /* tfeedback_decls */))
 goto done;
   } else
  demote_shader_inputs_and_outputs(sh, ir_var_shader_in);
@@ -3372,12 +3369,10 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
 
   gl_shader *const sh_i = prog->_LinkedShaders[i];
   gl_shader *const sh_next = prog->_LinkedShaders[next];
-  unsigned gs_input_vertices =
- next == MESA_SHADER_GEOMETRY ? prog->Geom.VerticesIn : 0;
 
   if (!assign_varying_locations(ctx, mem_ctx, prog, sh_i, sh_next,
 next == MESA_SHADER_FRAGMENT ? num

[Mesa-dev] [PATCH 11/46] mesa: support tess stages in glGetProgramPipelineiv

2015-06-16 Thread Marek Olšák
From: Fabian Bieler 

---
 src/mesa/main/pipelineobj.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index b4795ff..591b1aa 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -587,6 +587,7 @@ _mesa_GetProgramPipelineiv(GLuint pipeline, GLenum pname, 
GLint *params)
/* Are geometry shaders available in this context?
 */
const bool has_gs = _mesa_has_geometry_shaders(ctx);
+   const bool has_tess = _mesa_has_tessellation(ctx);;
 
if (!pipe) {
   _mesa_error(ctx, GL_INVALID_OPERATION,
@@ -614,11 +615,17 @@ _mesa_GetProgramPipelineiv(GLuint pipeline, GLenum pname, 
GLint *params)
  ? pipe->CurrentProgram[MESA_SHADER_VERTEX]->Name : 0;
   return;
case GL_TESS_EVALUATION_SHADER:
-  /* NOT YET SUPPORTED */
-  break;
+  if (!has_tess)
+ break;
+  *params = pipe->CurrentProgram[MESA_SHADER_TESS_EVAL]
+ ? pipe->CurrentProgram[MESA_SHADER_TESS_EVAL]->Name : 0;
+  return;
case GL_TESS_CONTROL_SHADER:
-  /* NOT YET SUPPORTED */
-  break;
+  if (!has_tess)
+ break;
+  *params = pipe->CurrentProgram[MESA_SHADER_TESS_CTRL]
+ ? pipe->CurrentProgram[MESA_SHADER_TESS_CTRL]->Name : 0;
+  return;
case GL_GEOMETRY_SHADER:
   if (!has_gs)
  break;
-- 
2.1.0

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


[Mesa-dev] [PATCH 19/46] mesa: don't allow drawing with tess ctrl shader and without tess eval shader

2015-06-16 Thread Marek Olšák
From: Marek Olšák 

---
 src/mesa/main/api_validate.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 401120a..9a5ac69 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -69,6 +69,25 @@ check_valid_to_render(struct gl_context *ctx, const char 
*function)
  return false;
   }
 
+  /* The spec argues that this is allowed because a tess ctrl shader
+   * without a tess eval shader can be used with transform feedback.
+   * However, glBeginTransformFeedback doesn't allow GL_PATCHES and
+   * therefore doesn't allow tessellation.
+   *
+   * Further investigation showed that this is indeed a spec bug and
+   * a tess ctrl shader without a tess eval shader shouldn't have been
+   * allowed, because there is no API in GL 4.0 that can make use this
+   * to produce something useful.
+   *
+   * Also, all vendors except one don't support a tess ctrl shader without
+   * a tess eval shader anyway.
+   */
+  if (ctx->TessCtrlProgram._Current && !ctx->TessEvalProgram._Current) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(tess eval shader is missing)", function);
+ return false;
+  }
+
   /* Section 7.3 (Program Objects) of the OpenGL 4.5 Core Profile spec
* says:
*
-- 
2.1.0

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


[Mesa-dev] [PATCH 20/46] glsl: add tessellation shader parsing support.

2015-06-16 Thread Marek Olšák
From: Fabian Bieler 

---
 src/glsl/ast.h  |  54 +++-
 src/glsl/ast_to_hir.cpp | 133 +++-
 src/glsl/ast_type.cpp   | 112 -
 src/glsl/glsl_parser.yy | 118 +--
 src/glsl/glsl_parser_extras.cpp |  39 +++-
 src/glsl/glsl_parser_extras.h   |  31 --
 6 files changed, 471 insertions(+), 16 deletions(-)

diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index ef74e51..26ad3bf 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -514,6 +514,17 @@ struct ast_type_qualifier {
  unsigned stream:1; /**< Has stream value assigned  */
  unsigned explicit_stream:1; /**< stream value assigned explicitly by 
shader code */
  /** \} */
+
+/** \name Layout qualifiers for GL_ARB_tessellation_shader */
+/** \{ */
+/* tess eval input layout */
+/* gs prim_type reused for primitive mode */
+unsigned vertex_spacing:1;
+unsigned ordering:1;
+unsigned point_mode:1;
+/* tess control output layout */
+unsigned vertices:1;
+/** \} */
   }
   /** \brief Set of flags, accessed by name. */
   q;
@@ -549,7 +560,10 @@ struct ast_type_qualifier {
/** Stream in GLSL 1.50 geometry shaders. */
unsigned stream;
 
-   /** Input or output primitive type in GLSL 1.50 geometry shaders */
+   /**
+* Input or output primitive type in GLSL 1.50 geometry shaders
+* and tessellation shaders.
+*/
GLenum prim_type;
 
/**
@@ -576,6 +590,18 @@ struct ast_type_qualifier {
 */
int local_size[3];
 
+   /** Tessellation evaluation shader: vertex spacing (equal, fractional 
even/odd) */
+   GLenum vertex_spacing;
+
+   /** Tessellation evaluation shader: vertex ordering (CW or CCW) */
+   GLenum ordering;
+
+   /** Tessellation evaluation shader: point mode */
+   bool point_mode;
+
+   /** Tessellation control shader: number of output vertices */
+   int vertices;
+
/**
 * Image format specified with an ARB_shader_image_load_store
 * layout qualifier.
@@ -631,6 +657,11 @@ struct ast_type_qualifier {
_mesa_glsl_parse_state *state,
ast_type_qualifier q);
 
+   bool merge_out_qualifier(YYLTYPE *loc,
+   _mesa_glsl_parse_state *state,
+   ast_type_qualifier q,
+   ast_node* &node);
+
bool merge_in_qualifier(YYLTYPE *loc,
_mesa_glsl_parse_state *state,
ast_type_qualifier q,
@@ -1031,6 +1062,27 @@ public:
 
 
 /**
+ * AST node representing a declaration of the output layout for tessellation
+ * control shaders.
+ */
+class ast_tcs_output_layout : public ast_node
+{
+public:
+   ast_tcs_output_layout(const struct YYLTYPE &locp, int vertices)
+  : vertices(vertices)
+   {
+  set_location(locp);
+   }
+
+   virtual ir_rvalue *hir(exec_list *instructions,
+  struct _mesa_glsl_parse_state *state);
+
+private:
+   const int vertices;
+};
+
+
+/**
  * AST node representing a declaration of the input layout for geometry
  * shaders.
  */
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 259e01e..53daf13 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -79,6 +79,7 @@ _mesa_ast_to_hir(exec_list *instructions, struct 
_mesa_glsl_parse_state *state)
state->toplevel_ir = instructions;
 
state->gs_input_prim_type_specified = false;
+   state->tcs_output_vertices_specified = false;
state->cs_input_local_size_specified = false;
 
/* Section 4.2 of the GLSL 1.20 specification states:
@@ -2205,6 +2206,8 @@ validate_explicit_location(const struct 
ast_type_qualifier *qual,
 * inputoutput
 * ---
 * vertex  explicit_loc sso
+* tess controlsso  sso
+* tess eval   sso  sso
 * geometrysso  sso
 * fragmentsso  explicit_loc
 */
@@ -2227,6 +2230,8 @@ validate_explicit_location(const struct 
ast_type_qualifier *qual,
   fail = true;
   break;
 
+   case MESA_SHADER_TESS_CTRL:
+   case MESA_SHADER_TESS_EVAL:
case MESA_SHADER_GEOMETRY:
   if (var->data.mode == ir_var_shader_in || var->data.mode == 
ir_var_shader_out) {
  if (!state->check_separate_shader_objects_allowed(loc, var))
@@ -2286,6 +2291,8 @@ validate_explicit_location(const struct 
ast_type_qualifier *qual,
: (qual->location + VARYING_SLOT_VAR0);
 break;
 
+ case MESA_SHADER_TESS_CTRL:
+ case MESA_SHADER_TESS_EVAL:
  case MESA_SHADER_GEOMETRY:
 var->data.location = qual->location + VARYING_SLOT_VAR0;
 break;
@@ -2564,7 +2571,9 @@ apply_type_qualifier_t

[Mesa-dev] [PATCH 34/46] glsl: properly size unsized arrays in tess stages

2015-06-16 Thread Marek Olšák
From: Chris Forbes 

---
 src/glsl/ast_to_hir.cpp | 49 +++--
 1 file changed, 47 insertions(+), 2 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 7ffe169..32e7f7f 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -3224,6 +3224,33 @@ handle_tess_ctrl_shader_output_decl(struct 
_mesa_glsl_parse_state *state,
 
 
 /**
+ * Do additional processing necessary for tessellation control/evaluation 
shader
+ * input declarations. This covers both interface block arrays and bare input
+ * variables.
+ */
+static void
+handle_tess_shader_input_decl(struct _mesa_glsl_parse_state *state,
+  YYLTYPE loc, ir_variable *var)
+{
+   if (!var->type->is_array() && !var->data.patch) {
+  _mesa_glsl_error(&loc, state,
+   "per-vertex tessellation shader inputs must be arrays");
+  /* Avoid cascading failures. */
+  return;
+   }
+
+   if (var->data.patch)
+  return;
+
+   /* Unsized arrays are implicitly sized to gl_MaxPatchVertices. */
+   if (var->type->is_unsized_array()) {
+  var->type = glsl_type::get_array_instance(var->type->fields.array,
+state->Const.MaxPatchVertices);
+   }
+}
+
+
+/**
  * Do additional processing necessary for geometry shader input declarations
  * (this covers both interface blocks arrays and bare input variables).
  */
@@ -3779,6 +3806,9 @@ ast_declarator_list::hir(exec_list *instructions,
   }
}
 }
+ } else if (state->stage == MESA_SHADER_TESS_CTRL ||
+state->stage == MESA_SHADER_TESS_EVAL) {
+handle_tess_shader_input_decl(state, loc, var);
  }
   } else if (var->data.mode == ir_var_shader_out) {
  const glsl_type *check_type = var->type->without_array();
@@ -5938,8 +5968,18 @@ ast_interface_block::hir(exec_list *instructions,
if (state->stage == MESA_SHADER_GEOMETRY && this->array_specifier == NULL &&
var_mode == ir_var_shader_in) {
   _mesa_glsl_error(&loc, state, "geometry shader inputs must be arrays");
+   } else if ((state->stage == MESA_SHADER_TESS_CTRL ||
+   state->stage == MESA_SHADER_TESS_EVAL) &&
+  this->array_specifier == NULL &&
+  var_mode == ir_var_shader_in) {
+  _mesa_glsl_error(&loc, state, "per-vertex tessellation shader inputs 
must be arrays");
+   } else if (state->stage == MESA_SHADER_TESS_CTRL &&
+  this->array_specifier == NULL &&
+  var_mode == ir_var_shader_out) {
+  _mesa_glsl_error(&loc, state, "tessellation control shader outputs must 
be arrays");
}
 
+
/* Page 39 (page 45 of the PDF) of section 4.3.7 in the GLSL ES 3.00 spec
 * says:
 *
@@ -6047,6 +6087,11 @@ ast_interface_block::hir(exec_list *instructions,
 
   if (state->stage == MESA_SHADER_GEOMETRY && var_mode == ir_var_shader_in)
  handle_geometry_shader_input_decl(state, loc, var);
+  else if ((state->stage == MESA_SHADER_TESS_CTRL ||
+   state->stage == MESA_SHADER_TESS_EVAL) && var_mode == 
ir_var_shader_in)
+ handle_tess_shader_input_decl(state, loc, var);
+  else if (state->stage == MESA_SHADER_TESS_CTRL && var_mode == 
ir_var_shader_out)
+ handle_tess_ctrl_shader_output_decl(state, loc, var);
 
   if (ir_variable *earlier =
   state->symbols->get_variable(this->instance_name)) {
@@ -6229,8 +6274,8 @@ ast_tcs_output_layout::hir(exec_list *instructions,
 continue;
 
   /* Note: Not all tessellation control shader output are arrays. */
-  if (!var->type->is_unsized_array())
-continue;
+  if (!var->type->is_unsized_array() || var->data.patch)
+ continue;
 
   if (var->data.max_array_access >= num_vertices) {
 _mesa_glsl_error(&loc, state,
-- 
2.1.0

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


[Mesa-dev] [PATCH 28/46] glsl: don't lower variable indexing on non-patch tessellation inputs/outputs

2015-06-16 Thread Marek Olšák
From: Marek Olšák 

There is no way to lower them, because the array sizes are unknown
at compile time.

Based on a patch from: Fabian Bieler 
---
 src/glsl/ir_optimization.h   |  5 +--
 src/glsl/lower_variable_index_to_cond_assign.cpp | 43 +---
 src/glsl/test_optpass.cpp|  3 +-
 src/mesa/drivers/dri/i965/brw_shader.cpp |  8 +++--
 src/mesa/program/ir_to_mesa.cpp  |  2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp   |  2 +-
 6 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
index 688a5e1..a174c96 100644
--- a/src/glsl/ir_optimization.h
+++ b/src/glsl/ir_optimization.h
@@ -114,8 +114,9 @@ bool lower_discard(exec_list *instructions);
 void lower_discard_flow(exec_list *instructions);
 bool lower_instructions(exec_list *instructions, unsigned what_to_lower);
 bool lower_noise(exec_list *instructions);
-bool lower_variable_index_to_cond_assign(exec_list *instructions,
-bool lower_input, bool lower_output, bool lower_temp, bool lower_uniform);
+bool lower_variable_index_to_cond_assign(gl_shader_stage stage,
+exec_list *instructions, bool lower_input, bool lower_output,
+bool lower_temp, bool lower_uniform);
 bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
 bool lower_const_arrays_to_uniforms(exec_list *instructions);
 bool lower_clip_distance(gl_shader *shader);
diff --git a/src/glsl/lower_variable_index_to_cond_assign.cpp 
b/src/glsl/lower_variable_index_to_cond_assign.cpp
index d878cb0..b6421f5 100644
--- a/src/glsl/lower_variable_index_to_cond_assign.cpp
+++ b/src/glsl/lower_variable_index_to_cond_assign.cpp
@@ -335,12 +335,14 @@ struct switch_generator
 
 class variable_index_to_cond_assign_visitor : public ir_rvalue_visitor {
 public:
-   variable_index_to_cond_assign_visitor(bool lower_input,
-bool lower_output,
-bool lower_temp,
-bool lower_uniform)
+   variable_index_to_cond_assign_visitor(gl_shader_stage stage,
+ bool lower_input,
+ bool lower_output,
+ bool lower_temp,
+ bool lower_uniform)
{
   this->progress = false;
+  this->stage = stage;
   this->lower_inputs = lower_input;
   this->lower_outputs = lower_output;
   this->lower_temps = lower_temp;
@@ -348,6 +350,8 @@ public:
}
 
bool progress;
+
+   gl_shader_stage stage;
bool lower_inputs;
bool lower_outputs;
bool lower_temps;
@@ -369,17 +373,28 @@ public:
   case ir_var_auto:
   case ir_var_temporary:
 return this->lower_temps;
+
   case ir_var_uniform:
 return this->lower_uniforms;
+
   case ir_var_function_in:
   case ir_var_const_in:
  return this->lower_temps;
+
   case ir_var_shader_in:
+ if ((stage == MESA_SHADER_TESS_CTRL ||
+  stage == MESA_SHADER_TESS_EVAL) && !var->data.patch)
+return false;
  return this->lower_inputs;
+
   case ir_var_function_out:
+ if (stage == MESA_SHADER_TESS_CTRL && !var->data.patch)
+return false;
  return this->lower_temps;
+
   case ir_var_shader_out:
  return this->lower_outputs;
+
   case ir_var_function_inout:
 return this->lower_temps;
   }
@@ -522,16 +537,18 @@ public:
 } /* anonymous namespace */
 
 bool
-lower_variable_index_to_cond_assign(exec_list *instructions,
-   bool lower_input,
-   bool lower_output,
-   bool lower_temp,
-   bool lower_uniform)
+lower_variable_index_to_cond_assign(gl_shader_stage stage,
+exec_list *instructions,
+bool lower_input,
+bool lower_output,
+bool lower_temp,
+bool lower_uniform)
 {
-   variable_index_to_cond_assign_visitor v(lower_input,
-  lower_output,
-  lower_temp,
-  lower_uniform);
+   variable_index_to_cond_assign_visitor v(stage,
+   lower_input,
+   lower_output,
+   lower_temp,
+   lower_uniform);
 
/* Continue lowering until no progress is made.  If there are multiple
 * levels of indirection (e.g., non-constant indexing of array elements and
diff --git a/src/glsl/test_optpass.cpp b/src/glsl/test_optpass.cpp
index

[Mesa-dev] [PATCH 25/46] glsl: lower gl_TessLevel* from float[n] to vecn.

2015-06-16 Thread Marek Olšák
From: Fabian Bieler 

Similar to gl_ClipDistance -> gl_ClipDistanceMESA
---
 src/glsl/Makefile.sources   |   1 +
 src/glsl/ir_optimization.h  |   1 +
 src/glsl/link_varyings.cpp  |  51 +++-
 src/glsl/link_varyings.h|  13 +-
 src/glsl/linker.cpp |   4 +
 src/glsl/lower_tess_level.cpp   | 462 
 src/mesa/drivers/dri/i965/brw_context.c |   1 +
 src/mesa/main/mtypes.h  |   1 +
 8 files changed, 521 insertions(+), 13 deletions(-)
 create mode 100644 src/glsl/lower_tess_level.cpp

diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index d784a81..b3b84d6 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -154,6 +154,7 @@ LIBGLSL_FILES = \
lower_packed_varyings.cpp \
lower_named_interface_blocks.cpp \
lower_packing_builtins.cpp \
+   lower_tess_level.cpp \
lower_texture_projection.cpp \
lower_variable_index_to_cond_assign.cpp \
lower_vec_index_to_cond_assign.cpp \
diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
index e6939f3..688a5e1 100644
--- a/src/glsl/ir_optimization.h
+++ b/src/glsl/ir_optimization.h
@@ -132,6 +132,7 @@ bool optimize_split_arrays(exec_list *instructions, bool 
linked);
 bool lower_offset_arrays(exec_list *instructions);
 void optimize_dead_builtin_variables(exec_list *instructions,
  enum ir_variable_mode other);
+bool lower_tess_level(gl_shader *shader);
 
 bool lower_vertex_id(gl_shader *shader);
 
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 373d337..d439b62 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -318,7 +318,7 @@ tfeedback_decl::init(struct gl_context *ctx, const void 
*mem_ctx,
 
this->location = -1;
this->orig_name = input;
-   this->is_clip_distance_mesa = false;
+   this->is_mesa_var = none;
this->skip_components = 0;
this->next_buffer_separator = false;
this->matched_candidate = NULL;
@@ -367,8 +367,15 @@ tfeedback_decl::init(struct gl_context *ctx, const void 
*mem_ctx,
 */
if (ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].LowerClipDistance 
&&
strcmp(this->var_name, "gl_ClipDistance") == 0) {
-  this->is_clip_distance_mesa = true;
+  this->is_mesa_var = clip_distance;
}
+
+   if (ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].LowerTessLevel &&
+   (strcmp(this->var_name, "gl_TessLevelOuter") == 0))
+  this->is_mesa_var = tess_level_outer;
+   if (ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].LowerTessLevel &&
+   (strcmp(this->var_name, "gl_TessLevelInner") == 0))
+  this->is_mesa_var = tess_level_inner;
 }
 
 
@@ -415,9 +422,22 @@ tfeedback_decl::assign_location(struct gl_context *ctx,
  this->matched_candidate->type->fields.array->matrix_columns;
   const unsigned vector_elements =
  this->matched_candidate->type->fields.array->vector_elements;
-  unsigned actual_array_size = this->is_clip_distance_mesa ?
- prog->LastClipDistanceArraySize :
- this->matched_candidate->type->array_size();
+  unsigned actual_array_size;
+  switch (this->is_mesa_var) {
+  case clip_distance:
+ actual_array_size = prog->LastClipDistanceArraySize;
+ break;
+  case tess_level_outer:
+ actual_array_size = 4;
+ break;
+  case tess_level_inner:
+ actual_array_size = 2;
+ break;
+  case none:
+  default:
+ actual_array_size = this->matched_candidate->type->array_size();
+ break;
+  }
 
   if (this->is_subscripted) {
  /* Check array bounds. */
@@ -428,7 +448,7 @@ tfeedback_decl::assign_location(struct gl_context *ctx,
  actual_array_size);
 return false;
  }
- unsigned array_elem_size = this->is_clip_distance_mesa ?
+ unsigned array_elem_size = this->is_mesa_var ?
 1 : vector_elements * matrix_cols;
  fine_location += array_elem_size * this->array_subscript;
  this->size = 1;
@@ -437,7 +457,7 @@ tfeedback_decl::assign_location(struct gl_context *ctx,
   }
   this->vector_elements = vector_elements;
   this->matrix_columns = matrix_cols;
-  if (this->is_clip_distance_mesa)
+  if (this->is_mesa_var)
  this->type = GL_FLOAT;
   else
  this->type = this->matched_candidate->type->fields.array->gl_type;
@@ -560,8 +580,21 @@ const tfeedback_candidate *
 tfeedback_decl::find_candidate(gl_shader_program *prog,
hash_table *tfeedback_candidates)
 {
-   const char *name = this->is_clip_distance_mesa
-  ? "gl_ClipDistanceMESA" : this->var_name;
+   const char *name = this->var_name;
+   switch (this->is_mesa_var) {
+   case none:
+  name = this->var_name;
+  break;
+   case clip_distance:

[Mesa-dev] [PATCH 26/46] glsl: add "in" or "out" prefix to name when flattening interface blocks

2015-06-16 Thread Marek Olšák
From: Fabian Bieler 

This is to prevent a name conflict in tessellation shaders built-in interface
blocks.
---
 src/glsl/lower_named_interface_blocks.cpp | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/glsl/lower_named_interface_blocks.cpp 
b/src/glsl/lower_named_interface_blocks.cpp
index 2f1e3af..29606f7 100644
--- a/src/glsl/lower_named_interface_blocks.cpp
+++ b/src/glsl/lower_named_interface_blocks.cpp
@@ -125,7 +125,8 @@ flatten_named_interface_blocks_declarations::run(exec_list 
*instructions)
   for (unsigned i = 0; i < iface_t->length; i++) {
  const char * field_name = iface_t->fields.structure[i].name;
  char *iface_field_name =
-ralloc_asprintf(mem_ctx, "%s.%s.%s",
+ralloc_asprintf(mem_ctx, "%s %s.%s.%s",
+var->data.mode == ir_var_shader_in ? "in" : "out",
 iface_t->name, var->name, field_name);
 
  ir_variable *found_var =
@@ -218,7 +219,9 @@ 
flatten_named_interface_blocks_declarations::handle_rvalue(ir_rvalue **rvalue)
 
if (var->get_interface_type() != NULL) {
   char *iface_field_name =
- ralloc_asprintf(mem_ctx, "%s.%s.%s", var->get_interface_type()->name,
+ ralloc_asprintf(mem_ctx, "%s %s.%s.%s",
+ var->data.mode == ir_var_shader_in ? "in" : "out",
+ var->get_interface_type()->name,
  var->name, ir->field);
   /* Find the variable in the set of flattened interface blocks */
   ir_variable *found_var =
-- 
2.1.0

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


[Mesa-dev] [PATCH 24/46] glsl: make lower_clip_distance work with tessellation shaders.

2015-06-16 Thread Marek Olšák
From: Fabian Bieler 

---
 src/glsl/lower_clip_distance.cpp | 185 ++-
 1 file changed, 105 insertions(+), 80 deletions(-)

diff --git a/src/glsl/lower_clip_distance.cpp b/src/glsl/lower_clip_distance.cpp
index 01f028b..1ada215 100644
--- a/src/glsl/lower_clip_distance.cpp
+++ b/src/glsl/lower_clip_distance.cpp
@@ -55,9 +55,9 @@ namespace {
 class lower_clip_distance_visitor : public ir_rvalue_visitor {
 public:
explicit lower_clip_distance_visitor(gl_shader_stage shader_stage)
-  : progress(false), old_clip_distance_1d_var(NULL),
-old_clip_distance_2d_var(NULL), new_clip_distance_1d_var(NULL),
-new_clip_distance_2d_var(NULL), shader_stage(shader_stage)
+  : progress(false), old_clip_distance_out_var(NULL),
+old_clip_distance_in_var(NULL), new_clip_distance_out_var(NULL),
+new_clip_distance_in_var(NULL), shader_stage(shader_stage)
{
}
 
@@ -80,20 +80,21 @@ public:
 *
 * Note:
 *
-* - the 2d_var is for geometry shader input only.
+* - the in_var is for geometry and both tessellation shader inputs only.
 *
-* - since gl_ClipDistance is available in geometry shaders as both an
-*   input and an output, it's possible for both old_clip_distance_1d_var
-*   and old_clip_distance_2d_var to be non-null.
+* - since gl_ClipDistance is available in tessellation control,
+*   tessellation evaluation and geometry shaders as both an input
+*   and an output, it's possible for both old_clip_distance_out_var
+*   and old_clip_distance_in_var to be non-null.
 */
-   ir_variable *old_clip_distance_1d_var;
-   ir_variable *old_clip_distance_2d_var;
+   ir_variable *old_clip_distance_out_var;
+   ir_variable *old_clip_distance_in_var;
 
/**
 * Pointer to the newly-created gl_ClipDistanceMESA variable.
 */
-   ir_variable *new_clip_distance_1d_var;
-   ir_variable *new_clip_distance_2d_var;
+   ir_variable *new_clip_distance_out_var;
+   ir_variable *new_clip_distance_in_var;
 
/**
 * Type of shader we are compiling (e.g. MESA_SHADER_VERTEX)
@@ -110,62 +111,81 @@ public:
 ir_visitor_status
 lower_clip_distance_visitor::visit(ir_variable *ir)
 {
+   ir_variable **old_var;
+   ir_variable **new_var;
+
if (!ir->name || strcmp(ir->name, "gl_ClipDistance") != 0)
   return visit_continue;
assert (ir->type->is_array());
 
-   if (!ir->type->fields.array->is_array()) {
-  /* 1D gl_ClipDistance (used for vertex and geometry output, and fragment
-   * input).
-   */
-  if (this->old_clip_distance_1d_var)
+   if (ir->data.mode == ir_var_shader_out) {
+  if (this->old_clip_distance_out_var)
+ return visit_continue;
+  old_var = &old_clip_distance_out_var;
+  new_var = &new_clip_distance_out_var;
+   } else if (ir->data.mode == ir_var_shader_in) {
+  if (this->old_clip_distance_in_var)
  return visit_continue;
+  old_var = &old_clip_distance_in_var;
+  new_var = &new_clip_distance_in_var;
+   } else {
+  unreachable("not reached");
+   }
 
-  this->progress = true;
-  this->old_clip_distance_1d_var = ir;
+   this->progress = true;
+
+   if (!ir->type->fields.array->is_array()) {
+  /* gl_ClipDistance (used for vertex, tessellation evaluation and
+   * geometry output, and fragment input).
+   */
+  assert((ir->data.mode == ir_var_shader_in &&
+  this->shader_stage == MESA_SHADER_FRAGMENT) ||
+ (ir->data.mode == ir_var_shader_out &&
+  (this->shader_stage == MESA_SHADER_VERTEX ||
+   this->shader_stage == MESA_SHADER_TESS_EVAL ||
+   this->shader_stage == MESA_SHADER_GEOMETRY)));
+
+  *old_var = ir;
   assert (ir->type->fields.array == glsl_type::float_type);
   unsigned new_size = (ir->type->array_size() + 3) / 4;
 
   /* Clone the old var so that we inherit all of its properties */
-  this->new_clip_distance_1d_var = ir->clone(ralloc_parent(ir), NULL);
+  *new_var = ir->clone(ralloc_parent(ir), NULL);
 
   /* And change the properties that we need to change */
-  this->new_clip_distance_1d_var->name
- = ralloc_strdup(this->new_clip_distance_1d_var,
- "gl_ClipDistanceMESA");
-  this->new_clip_distance_1d_var->type
- = glsl_type::get_array_instance(glsl_type::vec4_type, new_size);
-  this->new_clip_distance_1d_var->data.max_array_access
- = ir->data.max_array_access / 4;
-
-  ir->replace_with(this->new_clip_distance_1d_var);
+  (*new_var)->name = ralloc_strdup(*new_var, "gl_ClipDistanceMESA");
+  (*new_var)->type = glsl_type::get_array_instance(glsl_type::vec4_type,
+   new_size);
+  (*new_var)->data.max_array_access = ir->data.max_array_access / 4;
+
+  ir->replace_with(*new_var);
} else {
-  /* 2D gl_ClipDistance (used for geometry input). */
-  assert(ir->

[Mesa-dev] [PATCH 39/46] glsl: validate restrictions on use of barrier()

2015-06-16 Thread Marek Olšák
From: Chris Forbes 

With the exception of always-taken switch cases (which are
indistinguishable from straight line code in our IR), this
disallows use of the builtin barrier() function in all the
places it may not appear.

Signed-off-by: Chris Forbes 
---
 src/glsl/linker.cpp | 99 +
 1 file changed, 99 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 1315867..3639310 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -297,6 +297,97 @@ public:
}
 };
 
+class barrier_use_visitor : public ir_hierarchical_visitor {
+public:
+   barrier_use_visitor(gl_shader_program *prog)
+  : prog(prog), in_main(false), after_return(false), control_flow(0)
+   {
+   }
+
+   virtual ~barrier_use_visitor()
+   {
+  /* empty */
+   }
+
+   virtual ir_visitor_status visit_enter(ir_function *ir)
+   {
+  if (strcmp(ir->name, "main") == 0)
+ in_main = true;
+
+  return visit_continue;
+   }
+
+   virtual ir_visitor_status visit_leave(ir_function *ir)
+   {
+  in_main = false;
+  after_return = false;
+  return visit_continue;
+   }
+
+   virtual ir_visitor_status visit_leave(ir_return *ir)
+   {
+  after_return = true;
+  return visit_continue;
+   }
+
+   virtual ir_visitor_status visit_enter(ir_if *ir)
+   {
+  ++control_flow;
+  return visit_continue;
+   }
+
+   virtual ir_visitor_status visit_leave(ir_if *ir)
+   {
+  --control_flow;
+  return visit_continue;
+   }
+
+   virtual ir_visitor_status visit_enter(ir_loop *ir)
+   {
+  ++control_flow;
+  return visit_continue;
+   }
+
+   virtual ir_visitor_status visit_leave(ir_loop *ir)
+   {
+  --control_flow;
+  return visit_continue;
+   }
+
+   /* FINISHME: `switch` is not expressed at the IR level -- it's already
+* been lowered to a mess of `if`s. We'll correctly disallow any use of
+* barrier() in a conditional path within the switch, but not in a path
+* which is always hit.
+*/
+
+   virtual ir_visitor_status visit_enter(ir_call *ir)
+   {
+  if (ir->use_builtin && strcmp(ir->callee_name(), "barrier") == 0) {
+ /* Use of barrier(); determine if it is legal: */
+ if (!in_main) {
+linker_error(prog, "Builtin barrier() may only be used in main");
+return visit_stop;
+ }
+
+ if (after_return) {
+linker_error(prog, "Builtin barrier() may not be used after 
return");
+return visit_stop;
+ }
+
+ if (control_flow != 0) {
+linker_error(prog, "Builtin barrier() may not be used inside 
control flow");
+return visit_stop;
+ }
+  }
+  return visit_continue;
+   }
+
+private:
+   gl_shader_program *prog;
+   bool in_main, after_return;
+   int control_flow;
+};
+
 /**
  * Visitor that determines the highest stream id to which a (geometry) shader
  * emits vertices. It also checks whether End{Stream}Primitive is ever called.
@@ -1999,6 +2090,14 @@ link_intrastage_shaders(void *mem_ctx,
if (ctx->Const.VertexID_is_zero_based)
   lower_vertex_id(linked);
 
+   /* Validate correct usage of barrier() in the tess control shader */
+   if (linked->Stage == MESA_SHADER_TESS_CTRL) {
+  barrier_use_visitor visitor(prog);
+  foreach_in_list(ir_instruction, ir, linked->ir) {
+ ir->accept(&visitor);
+  }
+   }
+
/* Make a pass over all variable declarations to ensure that arrays with
 * unspecified sizes have a size specified.  The size is inferred from the
 * max_array_access field.
-- 
2.1.0

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


[Mesa-dev] [PATCH 30/46] glsl: relax unsized input/output block arrays for TCS/TES

2015-06-16 Thread Marek Olšák
From: Chris Forbes 

---
 src/glsl/ast_to_hir.cpp | 33 ++---
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 837bac7..fb957a1 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -5938,16 +5938,35 @@ ast_interface_block::hir(exec_list *instructions,
   * geometry shader inputs. All other input and output block
   * arrays must specify an array size.
   *
+  * The same applies to tessellation shaders.
+  *
   * The upshot of this is that the only circumstance where an
   * interface array size *doesn't* need to be specified is on a
-  * geometry shader input.
+  * geometry shader input, tessellation control shader input,
+  * tessellation control shader output, and tessellation evaluation
+  * shader input.
   */
- if (this->array_specifier->is_unsized_array &&
- (state->stage != MESA_SHADER_GEOMETRY || 
!this->layout.flags.q.in)) {
-_mesa_glsl_error(&loc, state,
- "only geometry shader inputs may be unsized "
- "instance block arrays");
-
+ if (this->array_specifier->is_unsized_array) {
+bool allow_inputs = state->stage == MESA_SHADER_GEOMETRY ||
+state->stage == MESA_SHADER_TESS_CTRL ||
+state->stage == MESA_SHADER_TESS_EVAL;
+bool allow_outputs = state->stage == MESA_SHADER_TESS_CTRL;
+
+if (this->layout.flags.q.in) {
+   if (!allow_inputs)
+  _mesa_glsl_error(&loc, state,
+   "unsized input block arrays not allowed in 
this "
+   "shader stage");
+} else if (this->layout.flags.q.out) {
+   if (!allow_outputs)
+  _mesa_glsl_error(&loc, state,
+   "unsized output block arrays not allowed in 
this "
+   "shader stage");
+} else {
+   /* by elimination, this is a uniform block array */
+   _mesa_glsl_error(&loc, state,
+"unsized uniform block arrays not allowed");
+}
  }
 
  const glsl_type *block_array_type =
-- 
2.1.0

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


[Mesa-dev] [PATCH 38/46] glsl: allow barrier() in tessellation control shaders

2015-06-16 Thread Marek Olšák
From: Marek Olšák 

---
 src/glsl/builtin_functions.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index efab299..2175c66 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -413,8 +413,8 @@ fp64(const _mesa_glsl_parse_state *state)
 static bool
 barrier_supported(const _mesa_glsl_parse_state *state)
 {
-   return state->stage == MESA_SHADER_COMPUTE;
-   /* TODO: || stage->state == MESA_SHADER_TESS_CTRL; */
+   return state->stage == MESA_SHADER_COMPUTE ||
+  state->stage == MESA_SHADER_TESS_CTRL;
 }
 
 /** @} */
-- 
2.1.0

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


[Mesa-dev] [PATCH 44/46] glsl: fix locations of 2-dimensional varyings without varying packing

2015-06-16 Thread Marek Olšák
From: Marek Olšák 

---
 src/glsl/link_varyings.cpp | 37 -
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 5fa9ddf..6bd8dba 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -750,7 +750,9 @@ namespace {
 class varying_matches
 {
 public:
-   varying_matches(bool disable_varying_packing, bool consumer_is_fs);
+   varying_matches(bool disable_varying_packing,
+   gl_shader_stage producer_type,
+   gl_shader_stage consumer_type);
~varying_matches();
void record(ir_variable *producer_var, ir_variable *consumer_var);
unsigned assign_locations();
@@ -831,15 +833,18 @@ private:
 */
unsigned matches_capacity;
 
-   const bool consumer_is_fs;
+   gl_shader_stage producer_type;
+   gl_shader_stage consumer_type;
 };
 
 } /* anonymous namespace */
 
 varying_matches::varying_matches(bool disable_varying_packing,
- bool consumer_is_fs)
+ gl_shader_stage producer_type,
+ gl_shader_stage consumer_type)
: disable_varying_packing(disable_varying_packing),
- consumer_is_fs(consumer_is_fs)
+ producer_type(producer_type),
+ consumer_type(consumer_type)
 {
/* Note: this initial capacity is rather arbitrarily chosen to be large
 * enough for many cases without wasting an unreasonable amount of space.
@@ -890,7 +895,7 @@ varying_matches::record(ir_variable *producer_var, 
ir_variable *consumer_var)
}
 
if ((consumer_var == NULL && producer_var->type->contains_integer()) ||
-   !consumer_is_fs) {
+   consumer_type != MESA_SHADER_FRAGMENT) {
   /* Since this varying is not being consumed by the fragment shader, its
* interpolation type varying cannot possibly affect rendering.  Also,
* this variable is non-flat and is (or contains) an integer.
@@ -927,9 +932,22 @@ varying_matches::record(ir_variable *producer_var, 
ir_variable *consumer_var)
this->matches[this->num_matches].packing_order
   = this->compute_packing_order(var);
if (this->disable_varying_packing) {
-  unsigned slots = var->type->is_array()
- ? (var->type->length * var->type->fields.array->matrix_columns)
- : var->type->matrix_columns;
+  const struct glsl_type *type = var->type;
+  unsigned slots;
+
+  /* Some shader stages have 2-dimensional varyings. Use the inner type. */
+  if (!var->data.patch &&
+  ((var == producer_var && producer_type == MESA_SHADER_TESS_CTRL) ||
+   (var == consumer_var && (consumer_type == MESA_SHADER_TESS_CTRL ||
+consumer_type == MESA_SHADER_TESS_EVAL ||
+consumer_type == MESA_SHADER_GEOMETRY {
+ assert(type->is_array());
+ type = type->fields.array;
+  }
+
+  slots = (type->is_array()
+? (type->length * type->fields.array->matrix_columns)
+: type->matrix_columns);
   this->matches[this->num_matches].num_components = 4 * slots;
} else {
   this->matches[this->num_matches].num_components
@@ -1378,7 +1396,8 @@ assign_varying_locations(struct gl_context *ctx,
   (producer && producer->Stage == MESA_SHADER_TESS_CTRL);
 
varying_matches matches(disable_varying_packing,
-   consumer && consumer->Stage == 
MESA_SHADER_FRAGMENT);
+   producer ? producer->Stage : (gl_shader_stage)-1,
+   consumer ? consumer->Stage : (gl_shader_stage)-1);
hash_table *tfeedback_candidates
   = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare);
hash_table *consumer_inputs
-- 
2.1.0

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


[Mesa-dev] [PATCH 14/46] mesa: allow setting of patch parameters.

2015-06-16 Thread Marek Olšák
From: Marek Olšák 

Based on a patch from Fabian Bieler .
---
 src/mesa/main/mtypes.h|  5 +
 src/mesa/main/shaderapi.c | 44 ++--
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 07a4b97..5f49c25 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4089,6 +4089,11 @@ struct gl_driver_flags
 * gl_context::ImageUnits
 */
uint64_t NewImageUnits;
+
+   /**
+* gl_context::TessCtrlProgram::patch_default_*
+*/
+   uint64_t NewDefaultTessLevels;
 };
 
 struct gl_uniform_buffer_binding
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index a247250..210746c 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1999,13 +1999,53 @@ _mesa_CreateShaderProgramv(GLenum type, GLsizei count,
 extern void GLAPIENTRY
 _mesa_PatchParameteri(GLenum pname, GLint value)
 {
-   /* STUB */
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (!_mesa_has_tessellation(ctx)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "glPatchParameteri");
+  return;
+   }
+
+   if (pname != GL_PATCH_VERTICES) {
+  _mesa_error(ctx, GL_INVALID_ENUM, "glPatchParameteri");
+  return;
+   }
+
+   if (value <= 0 || value > ctx->Const.MaxPatchVertices) {
+  _mesa_error(ctx, GL_INVALID_VALUE, "glPatchParameteri");
+  return;
+   }
+
+   ctx->TessCtrlProgram.patch_vertices = value;
 }
 
 
 extern void GLAPIENTRY
 _mesa_PatchParameterfv(GLenum pname, const GLfloat *values)
 {
-   /* STUB */
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (!_mesa_has_tessellation(ctx)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "glPatchParameterfv");
+  return;
+   }
+
+   switch(pname) {
+   case GL_PATCH_DEFAULT_OUTER_LEVEL:
+  FLUSH_VERTICES(ctx, 0);
+  memcpy(ctx->TessCtrlProgram.patch_default_outer_level, values,
+ 4 * sizeof(GLfloat));
+  ctx->NewDriverState |= ctx->DriverFlags.NewDefaultTessLevels;
+  return;
+   case GL_PATCH_DEFAULT_INNER_LEVEL:
+  FLUSH_VERTICES(ctx, 0);
+  memcpy(ctx->TessCtrlProgram.patch_default_inner_level, values,
+ 2 * sizeof(GLfloat));
+  ctx->NewDriverState |= ctx->DriverFlags.NewDefaultTessLevels;
+  return;
+   default:
+  _mesa_error(ctx, GL_INVALID_ENUM, "glPatchParameterfv");
+  return;
+   }
 }
 
-- 
2.1.0

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


[Mesa-dev] [PATCH 17/46] mesa: add program interface queries for tessellation shaders

2015-06-16 Thread Marek Olšák
From: Marek Olšák 

Based on a patch by Chris Forbes .
---
 src/mesa/main/shader_query.cpp |  8 ++--
 src/mesa/main/uniforms.c   | 21 +++--
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index a6246a3..8438d19 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -829,6 +829,10 @@ stage_from_enum(GLenum ref)
switch (ref) {
case GL_REFERENCED_BY_VERTEX_SHADER:
   return MESA_SHADER_VERTEX;
+   case GL_REFERENCED_BY_TESS_CONTROL_SHADER:
+  return MESA_SHADER_TESS_CTRL;
+   case GL_REFERENCED_BY_TESS_EVALUATION_SHADER:
+  return MESA_SHADER_TESS_EVAL;
case GL_REFERENCED_BY_GEOMETRY_SHADER:
   return MESA_SHADER_GEOMETRY;
case GL_REFERENCED_BY_FRAGMENT_SHADER:
@@ -1014,6 +1018,8 @@ _mesa_program_resource_prop(struct gl_shader_program 
*shProg,
  goto invalid_enum;
   /* fallthrough */
case GL_REFERENCED_BY_VERTEX_SHADER:
+   case GL_REFERENCED_BY_TESS_CONTROL_SHADER:
+   case GL_REFERENCED_BY_TESS_EVALUATION_SHADER:
case GL_REFERENCED_BY_GEOMETRY_SHADER:
case GL_REFERENCED_BY_FRAGMENT_SHADER:
   switch (res->Type) {
@@ -1047,8 +1053,6 @@ _mesa_program_resource_prop(struct gl_shader_program 
*shProg,
 
/* GL_ARB_tessellation_shader */
case GL_IS_PER_PATCH:
-   case GL_REFERENCED_BY_TESS_CONTROL_SHADER:
-   case GL_REFERENCED_BY_TESS_EVALUATION_SHADER:
default:
   goto invalid_enum;
}
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 5548d1d..1ef1fb7 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -1092,6 +1092,21 @@ mesa_bufferiv(struct gl_shader_program *shProg, GLenum 
type,
   GL_REFERENCED_BY_VERTEX_SHADER, params,
   caller);
   return;
+
+   case GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER:
+   case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER:
+  _mesa_program_resource_prop(shProg, res, index,
+  GL_REFERENCED_BY_TESS_CONTROL_SHADER, params,
+  caller);
+  return;
+
+   case GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER:
+   case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER:
+  _mesa_program_resource_prop(shProg, res, index,
+  GL_REFERENCED_BY_TESS_EVALUATION_SHADER, 
params,
+  caller);
+  return;
+
case GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER:
case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER:
   _mesa_program_resource_prop(shProg, res, index,
@@ -1104,12 +1119,6 @@ mesa_bufferiv(struct gl_shader_program *shProg, GLenum 
type,
   GL_REFERENCED_BY_FRAGMENT_SHADER, params,
   caller);
   return;
-   case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER:
-  params[0] = GL_FALSE;
-  return;
-   case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER:
-  params[0] = GL_FALSE;
-  return;
default:
   _mesa_error(ctx, GL_INVALID_ENUM,
   "%s(pname 0x%x (%s))", caller, pname,
-- 
2.1.0

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


[Mesa-dev] [PATCH 37/46] glsl: analyze TES usage of gl_ClipDistance

2015-06-16 Thread Marek Olšák
From: Chris Forbes 

---
 src/glsl/linker.cpp   | 19 +++
 src/mesa/main/mtypes.h|  7 +++
 src/mesa/main/shaderapi.c |  1 +
 3 files changed, 27 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 5ee84fc..1315867 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -629,6 +629,17 @@ validate_vertex_shader_executable(struct gl_shader_program 
*prog,
   &prog->Vert.ClipDistanceArraySize);
 }
 
+void
+validate_tess_eval_shader_executable(struct gl_shader_program *prog,
+ struct gl_shader *shader)
+{
+   if (shader == NULL)
+  return;
+
+   analyze_clip_usage(prog, shader, &prog->TessEval.UsesClipDistance,
+  &prog->TessEval.ClipDistanceArraySize);
+}
+
 
 /**
  * Verify that a fragment shader executable meets all semantic requirements
@@ -3115,6 +3126,12 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
  case MESA_SHADER_VERTEX:
 validate_vertex_shader_executable(prog, sh);
 break;
+ case MESA_SHADER_TESS_CTRL:
+/* nothing to be done */
+break;
+ case MESA_SHADER_TESS_EVAL:
+validate_tess_eval_shader_executable(prog, sh);
+break;
  case MESA_SHADER_GEOMETRY:
 validate_geometry_shader_executable(prog, sh);
 break;
@@ -3134,6 +3151,8 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
 
if (num_shaders[MESA_SHADER_GEOMETRY] > 0)
   prog->LastClipDistanceArraySize = prog->Geom.ClipDistanceArraySize;
+   else if (num_shaders[MESA_SHADER_TESS_EVAL] > 0)
+  prog->LastClipDistanceArraySize = prog->TessEval.ClipDistanceArraySize;
else if (num_shaders[MESA_SHADER_VERTEX] > 0)
   prog->LastClipDistanceArraySize = prog->Vert.ClipDistanceArraySize;
else
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 25afd61..5de8e14 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2775,6 +2775,13 @@ struct gl_shader_program
   /** GL_CW or GL_CCW */
   GLenum VertexOrder;
   bool PointMode;
+  /**
+   * True if gl_ClipDistance is written to.  Copied into
+   * gl_tess_eval_program by _mesa_copy_linked_program_data().
+   */
+  GLboolean UsesClipDistance;
+  GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or
+ 0 if not present. */
} TessEval;
 
/**
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 3428680..0d7e21b 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -2057,6 +2057,7 @@ _mesa_copy_linked_program_data(gl_shader_stage type,
   dst_tep->Spacing = src->TessEval.Spacing;
   dst_tep->VertexOrder = src->TessEval.VertexOrder;
   dst_tep->PointMode = src->TessEval.PointMode;
+  dst->UsesClipDistanceOut = src->TessEval.UsesClipDistance;
   break;
}
case MESA_SHADER_GEOMETRY: {
-- 
2.1.0

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


[Mesa-dev] [PATCH 27/46] glsl: make stand-alone compiler work with tessellation shaders.

2015-06-16 Thread Marek Olšák
From: Fabian Bieler 

---
 src/glsl/main.cpp   | 8 +++-
 src/glsl/standalone_scaffolding.cpp | 1 +
 src/glsl/standalone_scaffolding.h   | 4 
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
index 2341298..df93a01 100644
--- a/src/glsl/main.cpp
+++ b/src/glsl/main.cpp
@@ -204,6 +204,8 @@ initialize_context(struct gl_context *ctx, gl_api api)
}
 
ctx->Const.GenerateTemporaryNames = true;
+   ctx->Const.MaxPatchVertices = 32;
+
ctx->Driver.NewShader = _mesa_new_shader;
 }
 
@@ -273,7 +275,7 @@ usage_fail(const char *name)
 {
 
const char *header =
-  "usage: %s [options] \n"
+  "usage: %s [options] \n"
   "\n"
   "Possible options are:\n";
printf(header, name);
@@ -373,6 +375,10 @@ main(int argc, char **argv)
   const char *const ext = & argv[optind][len - 5];
   if (strncmp(".vert", ext, 5) == 0 || strncmp(".glsl", ext, 5) == 0)
 shader->Type = GL_VERTEX_SHADER;
+  else if (strncmp(".tesc", ext, 5) == 0)
+shader->Type = GL_TESS_CONTROL_SHADER;
+  else if (strncmp(".tese", ext, 5) == 0)
+shader->Type = GL_TESS_EVALUATION_SHADER;
   else if (strncmp(".geom", ext, 5) == 0)
 shader->Type = GL_GEOMETRY_SHADER;
   else if (strncmp(".frag", ext, 5) == 0)
diff --git a/src/glsl/standalone_scaffolding.cpp 
b/src/glsl/standalone_scaffolding.cpp
index 00db61e..1153b90 100644
--- a/src/glsl/standalone_scaffolding.cpp
+++ b/src/glsl/standalone_scaffolding.cpp
@@ -135,6 +135,7 @@ void initialize_context_to_defaults(struct gl_context *ctx, 
gl_api api)
ctx->Extensions.ARB_shader_texture_lod = true;
ctx->Extensions.ARB_shading_language_420pack = true;
ctx->Extensions.ARB_shading_language_packing = true;
+   ctx->Extensions.ARB_tessellation_shader = true;
ctx->Extensions.ARB_texture_cube_map_array = true;
ctx->Extensions.ARB_texture_gather = true;
ctx->Extensions.ARB_texture_multisample = true;
diff --git a/src/glsl/standalone_scaffolding.h 
b/src/glsl/standalone_scaffolding.h
index 895dd27..dc6fb64 100644
--- a/src/glsl/standalone_scaffolding.h
+++ b/src/glsl/standalone_scaffolding.h
@@ -61,6 +61,10 @@ _mesa_shader_enum_to_shader_stage(GLenum v)
   return MESA_SHADER_FRAGMENT;
case GL_GEOMETRY_SHADER:
   return MESA_SHADER_GEOMETRY;
+   case GL_TESS_CONTROL_SHADER:
+  return MESA_SHADER_TESS_CTRL;
+   case GL_TESS_EVALUATION_SHADER:
+  return MESA_SHADER_TESS_EVAL;
case GL_COMPUTE_SHADER:
   return MESA_SHADER_COMPUTE;
default:
-- 
2.1.0

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


[Mesa-dev] [PATCH 01/46] drirc: drop support for Heaven 3.0, fixes tessellation in 4.0

2015-06-16 Thread Marek Olšák
From: Marek Olšák 

---
 src/mesa/drivers/dri/common/drirc | 23 +++
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/src/mesa/drivers/dri/common/drirc 
b/src/mesa/drivers/dri/common/drirc
index 145e707..97d961b 100644
--- a/src/mesa/drivers/dri/common/drirc
+++ b/src/mesa/drivers/dri/common/drirc
@@ -4,24 +4,15 @@
 Application bugs worked around in this file:
 
 
+* Unigine Heaven 3.0 and older contain too many bugs and can't be supported
+  by drivers that want to be compliant.
+
 * Various Unigine products don't use the #version and #extension GLSL
   directives, meaning they only get GLSL 1.10 and no extensions for their
   shaders.
   Enabling all extensions for Unigine fixes most issues, but the GLSL version
   is still 1.10.
 
-* Unigine Heaven 3.0 with ARB_texture_multisample uses a "ivec4 * vec4"
-  expression, which is illegal in GLSL 1.10.
-  Adding "#version 130" fixes this.
-
-* Unigine Heaven 3.0 with ARB_shader_bit_encoding uses the uint keyword, which
-  is illegal in GLSL 1.10.
-  Adding "#version 130" fixes this.
-
-* Unigine Heaven 3.0 with ARB_shader_bit_encoding uses a "uint & int"
-  expression, which is illegal in any GLSL version.
-  Disabling ARB_shader_bit_encoding fixes this.
-
 * If ARB_sample_shading is supported, Unigine Heaven 4.0 and Valley 1.0 uses
   an #extension directive in the middle of its shaders, which is illegal
   in GLSL.
@@ -45,18 +36,10 @@ TODO: document the other workarounds.

 
 
-
-
-
-
 

 
 
-
-
-
-
 

 
-- 
2.1.0

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


[Mesa-dev] [PATCH 46/46] mesa: implement GL_IS_PER_PATCH

2015-06-16 Thread Marek Olšák
From: Marek Olšák 

---
 src/mesa/main/shader_query.cpp | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 8438d19..65f9400 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -1050,9 +1050,15 @@ _mesa_program_resource_prop(struct gl_shader_program 
*shProg,
  goto invalid_operation;
   *val = RESOURCE_VAR(res)->data.index;
   return 1;
-
-   /* GL_ARB_tessellation_shader */
case GL_IS_PER_PATCH:
+  switch (res->Type) {
+  case GL_PROGRAM_INPUT:
+  case GL_PROGRAM_OUTPUT:
+ *val = RESOURCE_VAR(res)->data.patch;
+ return 1;
+  default:
+ goto invalid_operation;
+  }
default:
   goto invalid_enum;
}
-- 
2.1.0

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


[Mesa-dev] [PATCH 32/46] glsl: add builtin constants for ARB_tessellation_shader

2015-06-16 Thread Marek Olšák
From: Chris Forbes 

Limits from other extensions added by Marek.
---
 src/glsl/builtin_variables.cpp  | 40 
 src/glsl/glsl_parser_extras.cpp | 19 +++
 src/glsl/glsl_parser_extras.h   | 17 +
 3 files changed, 72 insertions(+), 4 deletions(-)

diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 874cb10..1b1b16f 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -671,8 +671,14 @@ builtin_variable_generator::generate_constants()
   if (!state->es_shader) {
  add_const("gl_MaxGeometryAtomicCounters",
state->Const.MaxGeometryAtomicCounters);
- add_const("gl_MaxTessControlAtomicCounters", 0);
- add_const("gl_MaxTessEvaluationAtomicCounters", 0);
+
+if (state->is_version(400, 0) ||
+ state->ARB_tessellation_shader_enable) {
+add_const("gl_MaxTessControlAtomicCounters",
+   state->Const.MaxTessControlAtomicCounters);
+add_const("gl_MaxTessEvaluationAtomicCounters",
+   state->Const.MaxTessEvaluationAtomicCounters);
+}
   }
}
 
@@ -692,8 +698,10 @@ builtin_variable_generator::generate_constants()
   if (!state->es_shader) {
  add_const("gl_MaxGeometryAtomicCounterBuffers",
state->Const.MaxGeometryAtomicCounterBuffers);
- add_const("gl_MaxTessControlAtomicCounterBuffers", 0);
- add_const("gl_MaxTessEvaluationAtomicCounterBuffers", 0);
+ add_const("gl_MaxTessControlAtomicCounterBuffers",
+   state->Const.MaxTessControlAtomicCounterBuffers);
+ add_const("gl_MaxTessEvaluationAtomicCounterBuffers",
+   state->Const.MaxTessEvaluationAtomicCounterBuffers);
   }
}
 
@@ -752,11 +760,35 @@ builtin_variable_generator::generate_constants()
 state->Const.MaxFragmentImageUniforms);
   add_const("gl_MaxCombinedImageUniforms",
 state->Const.MaxCombinedImageUniforms);
+
+  if (state->is_version(400, 0) ||
+  state->ARB_tessellation_shader_enable) {
+ add_const("gl_MaxTessControlImageUniforms",
+   state->Const.MaxTessControlImageUniforms);
+ add_const("gl_MaxTessEvaluationImageUniforms",
+   state->Const.MaxTessEvaluationImageUniforms);
+  }
}
 
if (state->is_version(410, 0) ||
state->ARB_viewport_array_enable)
   add_const("gl_MaxViewports", state->Const.MaxViewports);
+
+   if (state->is_version(400, 0) ||
+   state->ARB_tessellation_shader_enable) {
+  add_const("gl_MaxPatchVertices", state->Const.MaxPatchVertices);
+  add_const("gl_MaxTessGenLevel", state->Const.MaxTessGenLevel);
+  add_const("gl_MaxTessControlInputComponents", 
state->Const.MaxTessControlInputComponents);
+  add_const("gl_MaxTessControlOutputComponents", 
state->Const.MaxTessControlOutputComponents);
+  add_const("gl_MaxTessControlTextureImageUnits", 
state->Const.MaxTessControlTextureImageUnits);
+  add_const("gl_MaxTessEvaluationInputComponents", 
state->Const.MaxTessEvaluationInputComponents);
+  add_const("gl_MaxTessEvaluationOutputComponents", 
state->Const.MaxTessEvaluationOutputComponents);
+  add_const("gl_MaxTessEvaluationTextureImageUnits", 
state->Const.MaxTessEvaluationTextureImageUnits);
+  add_const("gl_MaxTessPatchComponents", 
state->Const.MaxTessPatchComponents);
+  add_const("gl_MaxTessControlTotalOutputComponents", 
state->Const.MaxTessControlTotalOutputComponents);
+  add_const("gl_MaxTessControlUniformComponents", 
state->Const.MaxTessControlUniformComponents);
+  add_const("gl_MaxTessEvaluationUniformComponents", 
state->Const.MaxTessEvaluationUniformComponents);
+   }
 }
 
 
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index b34c7b5..7867110 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -113,12 +113,18 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
this->Const.MaxGeometryUniformComponents = 
ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxUniformComponents;
 
this->Const.MaxVertexAtomicCounters = 
ctx->Const.Program[MESA_SHADER_VERTEX].MaxAtomicCounters;
+   this->Const.MaxTessControlAtomicCounters = 
ctx->Const.Program[MESA_SHADER_TESS_CTRL].MaxAtomicCounters;
+   this->Const.MaxTessEvaluationAtomicCounters = 
ctx->Const.Program[MESA_SHADER_TESS_EVAL].MaxAtomicCounters;
this->Const.MaxGeometryAtomicCounters = 
ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicCounters;
this->Const.MaxFragmentAtomicCounters = 
ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicCounters;
this->Const.MaxCombinedAtomicCounters = 
ctx->Const.MaxCombinedAtomicCounters;
this->Const.MaxAtomicBufferBindings = ctx->Const.MaxAtomicBufferBindings;
this->Const.MaxVertexAtomicCo

[Mesa-dev] [PATCH 21/46] glsl: add tessellation shader defines and built-in variables.

2015-06-16 Thread Marek Olšák
From: Fabian Bieler 

---
 src/glsl/builtin_variables.cpp | 72 +-
 src/glsl/glcpp/glcpp-parse.y   |  3 ++
 src/glsl/shader_enums.h| 13 +++-
 src/mesa/main/mtypes.h |  6 
 src/mesa/program/prog_print.c  |  4 +++
 5 files changed, 96 insertions(+), 2 deletions(-)

diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 6806aa1..bb947a8 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -343,6 +343,8 @@ public:
void generate_constants();
void generate_uniforms();
void generate_vs_special_vars();
+   void generate_tcs_special_vars();
+   void generate_tes_special_vars();
void generate_gs_special_vars();
void generate_fs_special_vars();
void generate_cs_special_vars();
@@ -870,6 +872,39 @@ builtin_variable_generator::generate_vs_special_vars()
 
 
 /**
+ * Generate variables which only exist in tessellation control shaders.
+ */
+void
+builtin_variable_generator::generate_tcs_special_vars()
+{
+   add_system_value(SYSTEM_VALUE_PRIMITIVE_ID, int_t, "gl_PrimitiveID");
+   add_system_value(SYSTEM_VALUE_VERTICES_IN, int_t, "gl_PatchVerticesIn");
+   add_system_value(SYSTEM_VALUE_INVOCATION_ID, int_t, "gl_InvocationID");
+
+   add_output(VARYING_SLOT_TESS_LEVEL_OUTER,
+array(float_t, 4), "gl_TessLevelOuter");
+   add_output(VARYING_SLOT_TESS_LEVEL_INNER,
+array(float_t, 2), "gl_TessLevelInner");
+}
+
+
+/**
+ * Generate variables which only exist in tessellation evaluation shaders.
+ */
+void
+builtin_variable_generator::generate_tes_special_vars()
+{
+   add_system_value(SYSTEM_VALUE_PRIMITIVE_ID, int_t, "gl_PrimitiveID");
+   add_system_value(SYSTEM_VALUE_VERTICES_IN, int_t, "gl_PatchVerticesIn");
+   add_system_value(SYSTEM_VALUE_TESS_COORD, vec3_t, "gl_TessCoord");
+   add_system_value(SYSTEM_VALUE_TESS_LEVEL_OUTER, array(float_t, 4),
+"gl_TessLevelOuter");
+   add_system_value(SYSTEM_VALUE_TESS_LEVEL_INNER, array(float_t, 2),
+"gl_TessLevelInner");
+}
+
+
+/**
  * Generate variables which only exist in geometry shaders.
  */
 void
@@ -992,6 +1027,8 @@ builtin_variable_generator::add_varying(int slot, const 
glsl_type *type,
 const char *name_as_gs_input)
 {
switch (state->stage) {
+   case MESA_SHADER_TESS_CTRL:
+   case MESA_SHADER_TESS_EVAL:
case MESA_SHADER_GEOMETRY:
   this->per_vertex_in.add_field(slot, type, name);
   /* FALLTHROUGH */
@@ -1044,13 +1081,40 @@ builtin_variable_generator::generate_varyings()
   }
}
 
+   /* Section 7.1 (Built-In Language Variables) of the GLSL 4.00 spec
+* says:
+*
+*"In the tessellation control language, built-in variables are
+*intrinsically declared as:
+*
+*in gl_PerVertex {
+*vec4 gl_Position;
+*float gl_PointSize;
+*float gl_ClipDistance[];
+*} gl_in[gl_MaxPatchVertices];"
+*/
+   if (state->stage == MESA_SHADER_TESS_CTRL ||
+   state->stage == MESA_SHADER_TESS_EVAL) {
+  const glsl_type *per_vertex_in_type =
+ this->per_vertex_in.construct_interface_instance();
+  add_variable("gl_in", array(per_vertex_in_type, 
state->Const.MaxPatchVertices),
+   ir_var_shader_in, -1);
+   }
if (state->stage == MESA_SHADER_GEOMETRY) {
   const glsl_type *per_vertex_in_type =
  this->per_vertex_in.construct_interface_instance();
   add_variable("gl_in", array(per_vertex_in_type, 0),
ir_var_shader_in, -1);
}
-   if (state->stage == MESA_SHADER_VERTEX || state->stage == 
MESA_SHADER_GEOMETRY) {
+   if (state->stage == MESA_SHADER_TESS_CTRL) {
+  const glsl_type *per_vertex_out_type =
+ this->per_vertex_out.construct_interface_instance();
+  add_variable("gl_out", array(per_vertex_out_type, 0),
+   ir_var_shader_out, -1);
+   }
+   if (state->stage == MESA_SHADER_VERTEX ||
+   state->stage == MESA_SHADER_TESS_EVAL ||
+   state->stage == MESA_SHADER_GEOMETRY) {
   const glsl_type *per_vertex_out_type =
  this->per_vertex_out.construct_interface_instance();
   const glsl_struct_field *fields = per_vertex_out_type->fields.structure;
@@ -1085,6 +1149,12 @@ _mesa_glsl_initialize_variables(exec_list *instructions,
case MESA_SHADER_VERTEX:
   gen.generate_vs_special_vars();
   break;
+   case MESA_SHADER_TESS_CTRL:
+  gen.generate_tcs_special_vars();
+  break;
+   case MESA_SHADER_TESS_EVAL:
+  gen.generate_tes_special_vars();
+  break;
case MESA_SHADER_GEOMETRY:
   gen.generate_gs_special_vars();
   break;
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index a11b6b2..7aaa9b1 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -2483,6 +2483,9 @@ _glcpp_parser_handle_version_decla

[Mesa-dev] [PATCH 04/46] mesa: add tessellation shader enums

2015-06-16 Thread Marek Olšák
From: Fabian Bieler 

---
 src/glsl/shader_enums.h | 8 +---
 src/mesa/drivers/common/meta.c  | 2 ++
 src/mesa/drivers/dri/i965/intel_debug.c | 4 +++-
 src/mesa/main/context.c | 2 ++
 src/mesa/main/shaderobj.h   | 4 
 src/mesa/program/prog_print.c   | 6 ++
 src/mesa/program/program.h  | 8 
 7 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
index 79e0f6b..42a30ae 100644
--- a/src/glsl/shader_enums.h
+++ b/src/glsl/shader_enums.h
@@ -36,9 +36,11 @@
 typedef enum
 {
MESA_SHADER_VERTEX = 0,
-   MESA_SHADER_GEOMETRY = 1,
-   MESA_SHADER_FRAGMENT = 2,
-   MESA_SHADER_COMPUTE = 3,
+   MESA_SHADER_TESS_CTRL = 1,
+   MESA_SHADER_TESS_EVAL = 2,
+   MESA_SHADER_GEOMETRY = 3,
+   MESA_SHADER_FRAGMENT = 4,
+   MESA_SHADER_COMPUTE = 5,
 } gl_shader_stage;
 
 #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 214a68a..526ba80 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -945,6 +945,8 @@ _mesa_meta_end(struct gl_context *ctx)
if (state & MESA_META_SHADER) {
   static const GLenum targets[] = {
  GL_VERTEX_SHADER,
+ GL_TESS_CONTROL_SHADER,
+ GL_TESS_EVALUATION_SHADER,
  GL_GEOMETRY_SHADER,
  GL_FRAGMENT_SHADER,
   };
diff --git a/src/mesa/drivers/dri/i965/intel_debug.c 
b/src/mesa/drivers/dri/i965/intel_debug.c
index 53f575a..f2aec54 100644
--- a/src/mesa/drivers/dri/i965/intel_debug.c
+++ b/src/mesa/drivers/dri/i965/intel_debug.c
@@ -79,11 +79,13 @@ intel_debug_flag_for_shader_stage(gl_shader_stage stage)
 {
uint64_t flags[] = {
   [MESA_SHADER_VERTEX] = DEBUG_VS,
+  [MESA_SHADER_TESS_CTRL] = 0,
+  [MESA_SHADER_TESS_EVAL] = 0,
   [MESA_SHADER_GEOMETRY] = DEBUG_GS,
   [MESA_SHADER_FRAGMENT] = DEBUG_WM,
   [MESA_SHADER_COMPUTE] = DEBUG_CS,
};
-   STATIC_ASSERT(MESA_SHADER_STAGES == 4);
+   STATIC_ASSERT(MESA_SHADER_STAGES == 6);
return flags[stage];
 }
 
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 79fa018..4875f47 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -496,6 +496,8 @@ init_program_limits(struct gl_constants *consts, 
gl_shader_stage stage,
   prog->MaxInputComponents = 16 * 4; /* old limit not to break tnl and 
swrast */
   prog->MaxOutputComponents = 0; /* value not used */
   break;
+   case MESA_SHADER_TESS_CTRL:
+   case MESA_SHADER_TESS_EVAL:
case MESA_SHADER_GEOMETRY:
   prog->MaxParameters = MAX_VERTEX_PROGRAM_PARAMS;
   prog->MaxAttribs = MAX_VERTEX_GENERIC_ATTRIBS;
diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h
index 3d696a1..75f019d 100644
--- a/src/mesa/main/shaderobj.h
+++ b/src/mesa/main/shaderobj.h
@@ -111,6 +111,10 @@ _mesa_shader_enum_to_shader_stage(GLenum v)
   return MESA_SHADER_FRAGMENT;
case GL_GEOMETRY_SHADER:
   return MESA_SHADER_GEOMETRY;
+   case GL_TESS_CONTROL_SHADER:
+  return MESA_SHADER_TESS_CTRL;
+   case GL_TESS_EVALUATION_SHADER:
+  return MESA_SHADER_TESS_EVAL;
case GL_COMPUTE_SHADER:
   return MESA_SHADER_COMPUTE;
default:
diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c
index e4faa63..336a5ef 100644
--- a/src/mesa/program/prog_print.c
+++ b/src/mesa/program/prog_print.c
@@ -1015,6 +1015,12 @@ _mesa_write_shader_to_file(const struct gl_shader 
*shader)
case MESA_SHADER_FRAGMENT:
   type = "frag";
   break;
+   case MESA_SHADER_TESS_CTRL:
+  type = "tesc";
+  break;
+   case MESA_SHADER_TESS_EVAL:
+  type = "tese";
+  break;
case MESA_SHADER_VERTEX:
   type = "vert";
   break;
diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
index 2d92ab2..396a5c8 100644
--- a/src/mesa/program/program.h
+++ b/src/mesa/program/program.h
@@ -216,6 +216,10 @@ _mesa_program_enum_to_shader_stage(GLenum v)
   return MESA_SHADER_FRAGMENT;
case GL_GEOMETRY_PROGRAM_NV:
   return MESA_SHADER_GEOMETRY;
+   case GL_TESS_CONTROL_PROGRAM_NV:
+  return MESA_SHADER_TESS_CTRL;
+   case GL_TESS_EVALUATION_PROGRAM_NV:
+  return MESA_SHADER_TESS_EVAL;
case GL_COMPUTE_PROGRAM_NV:
   return MESA_SHADER_COMPUTE;
default:
@@ -235,6 +239,10 @@ _mesa_shader_stage_to_program(unsigned stage)
   return GL_FRAGMENT_PROGRAM_ARB;
case MESA_SHADER_GEOMETRY:
   return GL_GEOMETRY_PROGRAM_NV;
+   case MESA_SHADER_TESS_CTRL:
+  return GL_TESS_CONTROL_PROGRAM_NV;
+   case MESA_SHADER_TESS_EVAL:
+  return GL_TESS_EVALUATION_PROGRAM_NV;
case MESA_SHADER_COMPUTE:
   return GL_COMPUTE_PROGRAM_NV;
}
-- 
2.1.0

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


[Mesa-dev] [PATCH 43/46] glsl: don't demote tess control shader outputs

2015-06-16 Thread Marek Olšák
From: Marek Olšák 

---
 src/glsl/link_varyings.cpp | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index a4d0f1c..5fa9ddf 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -1451,8 +1451,12 @@ assign_varying_locations(struct gl_context *ctx,
  /* If a matching input variable was found, add this ouptut (and the
   * input) to the set.  If this is a separable program and there is no
   * consumer stage, add the output.
+  *
+  * Always add TCS outputs. They are shared by all invocations
+  * within a patch and can be used as shared memory.
   */
- if (input_var || (prog->SeparateShader && consumer == NULL)) {
+ if (input_var || (prog->SeparateShader && consumer == NULL) ||
+ producer->Type == GL_TESS_CONTROL_SHADER) {
 matches.record(output_var, input_var);
  }
 
-- 
2.1.0

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


[Mesa-dev] [PATCH 15/46] mesa: add tessellation shader getters.

2015-06-16 Thread Marek Olšák
From: Fabian Bieler 

Tessellation dependencies added by Marek.
---
 src/mesa/main/get.c  |  1 +
 src/mesa/main/get_hash_params.py | 28 ++
 src/mesa/main/shaderapi.c| 84 
 3 files changed, 113 insertions(+)

diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 1bc9b5d..6f2e1ec 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -400,6 +400,7 @@ EXTRA_EXT(INTEL_performance_query);
 EXTRA_EXT(ARB_explicit_uniform_location);
 EXTRA_EXT(ARB_clip_control);
 EXTRA_EXT(EXT_polygon_offset_clamp);
+EXTRA_EXT(ARB_tessellation_shader);
 
 static const int
 extra_ARB_color_buffer_float_or_glcore[] = {
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index 513d5d2..6d393cc 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -820,6 +820,34 @@ descriptor=[
 
 # GL_EXT_polygon_offset_clamp
   [ "POLYGON_OFFSET_CLAMP_EXT", "CONTEXT_FLOAT(Polygon.OffsetClamp), 
extra_EXT_polygon_offset_clamp" ],
+
+# GL_ARB_tessellation_shader
+  [ "PATCH_VERTICES", "CONTEXT_INT(TessCtrlProgram.patch_vertices), 
extra_ARB_tessellation_shader" ],
+  [ "PATCH_DEFAULT_OUTER_LEVEL", 
"CONTEXT_FLOAT4(TessCtrlProgram.patch_default_outer_level), 
extra_ARB_tessellation_shader" ],
+  [ "PATCH_DEFAULT_INNER_LEVEL", 
"CONTEXT_FLOAT2(TessCtrlProgram.patch_default_inner_level), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_TESS_GEN_LEVEL", "CONTEXT_INT(Const.MaxTessGenLevel), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_PATCH_VERTICES", "CONTEXT_INT(Const.MaxPatchVertices), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_TESS_CONTROL_UNIFORM_COMPONENTS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxUniformComponents), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_TESS_EVALUATION_UNIFORM_COMPONENTS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxUniformComponents), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxTextureImageUnits), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxTextureImageUnits), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_TESS_CONTROL_OUTPUT_COMPONENTS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxOutputComponents), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_TESS_PATCH_COMPONENTS", "CONTEXT_INT(Const.MaxTessPatchComponents), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS", 
"CONTEXT_INT(Const.MaxTessControlTotalOutputComponents), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_TESS_EVALUATION_OUTPUT_COMPONENTS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxOutputComponents), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_TESS_CONTROL_INPUT_COMPONENTS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxInputComponents), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_TESS_EVALUATION_INPUT_COMPONENTS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxInputComponents), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_TESS_CONTROL_UNIFORM_BLOCKS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxUniformBlocks), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_TESS_EVALUATION_UNIFORM_BLOCKS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxUniformBlocks), 
extra_ARB_tessellation_shader" ],
+  [ "MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxCombinedUniformComponents),
 extra_ARB_tessellation_shader" ],
+  [ "MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxCombinedUniformComponents),
 extra_ARB_tessellation_shader" ],
+# Dependencies on GL_ARB_tessellation_shader
+  [ "MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxAtomicBuffers), 
extra_ARB_shader_atomic_counters" ],
+  [ "MAX_TESS_CONTROL_ATOMIC_COUNTERS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxAtomicCounters), 
extra_ARB_shader_atomic_counters" ],
+  [ "MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxAtomicBuffers), 
extra_ARB_shader_atomic_counters" ],
+  [ "MAX_TESS_EVALUATION_ATOMIC_COUNTERS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxAtomicCounters), 
extra_ARB_shader_atomic_counters" ],
+  [ "MAX_TESS_CONTROL_IMAGE_UNIFORMS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxImageUniforms), 
extra_ARB_shader_image_load_store"],
+  [ "MAX_TESS_EVALUATION_IMAGE_UNIFORMS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxImageUniforms), 
extra_ARB_shader_image_load_store"],
 ]}
 
 ]
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 210746c..b9f6afb 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -518,6 +518,57 @@ check_gs_query(struct gl_context *ctx, const struct 
gl_shader_program *shProg)
 
 

[Mesa-dev] [PATCH 41/46] glsl: allow indexing of gl_out with a non-const if length isn't known

2015-06-16 Thread Marek Olšák
From: Marek Olšák 

---
 src/glsl/ast_array_index.cpp | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/glsl/ast_array_index.cpp b/src/glsl/ast_array_index.cpp
index 0130c14..0b6b5c7 100644
--- a/src/glsl/ast_array_index.cpp
+++ b/src/glsl/ast_array_index.cpp
@@ -216,6 +216,16 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
 if (v != NULL)
v->data.max_array_access = implicit_size - 1;
  }
+ else if (state->stage == MESA_SHADER_TESS_CTRL &&
+  array->variable_referenced()->data.mode == ir_var_shader_out 
&&
+  !array->variable_referenced()->data.patch) {
+/* Tessellation control shader output non-patch arrays are
+ * initially unsized. Despite that, they are allowed to be
+ * indexed with a non-constant expression (typically
+ * "gl_InvocationID"). The array size will be determined
+ * by the linker.
+ */
+ }
  else {
 _mesa_glsl_error(&loc, state, "unsized array index must be 
constant");
  }
-- 
2.1.0

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


[Mesa-dev] [PATCH 18/46] mesa: handle tessellation shaders in use_shader_program

2015-06-16 Thread Marek Olšák
From: Marek Olšák 

---
 src/mesa/main/shaderapi.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 1cc3e37..3428680 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1139,11 +1139,9 @@ use_shader_program(struct gl_context *ctx, 
gl_shader_stage stage,
*/
   switch (stage) {
   case MESA_SHADER_VERTEX:
-/* Empty for now. */
-break;
+  case MESA_SHADER_TESS_CTRL:
+  case MESA_SHADER_TESS_EVAL:
   case MESA_SHADER_GEOMETRY:
-/* Empty for now. */
-break;
   case MESA_SHADER_COMPUTE:
  /* Empty for now. */
  break;
-- 
2.1.0

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


[Mesa-dev] [PATCH 42/46] glsl: disable varying packing between tessellation shaders

2015-06-16 Thread Marek Olšák
From: Marek Olšák 

---
 src/glsl/link_varyings.cpp | 29 +
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 2f7d19b..a4d0f1c 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -1358,7 +1358,26 @@ assign_varying_locations(struct gl_context *ctx,
  unsigned num_tfeedback_decls,
  tfeedback_decl *tfeedback_decls)
 {
-   varying_matches matches(ctx->Const.DisableVaryingPacking,
+   if (ctx->Const.DisableVaryingPacking) {
+  /* Transform feedback code assumes varyings are packed, so if the driver
+   * has disabled varying packing, make sure it does not support transform
+   * feedback.
+   */
+  assert(!ctx->Extensions.EXT_transform_feedback);
+   }
+
+   /* Tessellation shaders treat inputs and outputs as shared memory and can
+* access inputs and outputs of other invocations.
+* Therefore, they can't be lowered to temps easily (and definitely not
+* efficiently).
+*/
+   bool disable_varying_packing =
+  ctx->Const.DisableVaryingPacking ||
+  (consumer && consumer->Stage == MESA_SHADER_TESS_EVAL) ||
+  (consumer && consumer->Stage == MESA_SHADER_TESS_CTRL) ||
+  (producer && producer->Stage == MESA_SHADER_TESS_CTRL);
+
+   varying_matches matches(disable_varying_packing,
consumer && consumer->Stage == 
MESA_SHADER_FRAGMENT);
hash_table *tfeedback_candidates
   = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare);
@@ -1500,13 +1519,7 @@ assign_varying_locations(struct gl_context *ctx,
hash_table_dtor(consumer_inputs);
hash_table_dtor(consumer_interface_inputs);
 
-   if (ctx->Const.DisableVaryingPacking) {
-  /* Transform feedback code assumes varyings are packed, so if the driver
-   * has disabled varying packing, make sure it does not support transform
-   * feedback.
-   */
-  assert(!ctx->Extensions.EXT_transform_feedback);
-   } else {
+   if (!disable_varying_packing) {
   if (producer) {
  lower_packed_varyings(mem_ctx, slots_used, ir_var_shader_out,
0, producer);
-- 
2.1.0

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


  1   2   >