Re: [Mesa-dev] [PATCH] anv/cmd_buffer: Re-emit the pipeline at every subpass

2018-01-29 Thread Iago Toral
On Fri, 2018-01-26 at 16:23 -0800, Jason Ekstrand wrote:
> If we ever hit this edge-case, it can theoretically cause problem for
> CNL because we could end up changing render targets without re-
> emitting
> 3DSTATE_MULTISAMPLE which is part of the pipeline.  Just get rid of
> the
> edge case.
> 
> Cc: mesa-sta...@lists.freedesktop.org
> ---
>  src/intel/vulkan/genX_cmd_buffer.c | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/src/intel/vulkan/genX_cmd_buffer.c
> b/src/intel/vulkan/genX_cmd_buffer.c
> index e8d44d0..bf6e267 100644
> --- a/src/intel/vulkan/genX_cmd_buffer.c
> +++ b/src/intel/vulkan/genX_cmd_buffer.c
> @@ -3200,6 +3200,17 @@ genX(cmd_buffer_set_subpass)(struct
> anv_cmd_buffer *cmd_buffer,
> if (GEN_GEN == 7)
>cmd_buffer->state.gfx.vb_dirty |= ~0;
>  
> +   /* It is possible to start a render pass with an old
> pipeline.  Because the
> +* render pass and subpass index are both baked into the
> pipeline, this is
> +* highly unlikely.  In order to do so, it requires that you have
> a render
> +* pass with a single subpass and that you use that render pass
> twice
> +* back-to-back and use the same pipeline at the start of the
> second render
> +* pass as at the end of the first.  In order to avoid
> unpredictable issues
> +* with this edge case, we just dirty the pipeline at the start
> of every
> +* subpass.
> +*/
> +   cmd_buffer->state.gfx.dirty |= ANV_CMD_DIRTY_PIPELINE;
> +

I was going to say that since this can only happen when there is a
single subpass in the renderpass we could just do this at
CmdBeginRenderPass instead, but I guess it doesn't really matter since
apps need to bind a new pipeline at each subpass anyway and that will
dirty this state. It would be redundant for most cases but I guess it
does't hurt.

Reviewed-by: Iago Toral Quiroga 

Iago

> /* Perform transitions to the subpass layout before any writes
> have
>  * occurred.
>  */
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] glsl/linker: fix bug when checking precision qualifier

2018-01-29 Thread Samuel Iglesias Gonsálvez
According to GLSL ES 3.2 spec, see table in 9.2.1 "Linked Shaders"
section, the precision qualifier should match for uniform variables.
This also applies to previous GLSL ES 3.x specs.

This 'if' checks the condition for uniform variables, while for UBOs
it is checked in link_interface_blocks.cpp.

Fixes: b50b82b8a553
("glsl/es31: precision qualifier doesn't need to match in shader interface 
block members")

Signed-off-by: Samuel Iglesias Gonsálvez 
---
 src/compiler/glsl/linker.cpp | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index ce101935b01..050b2906f6b 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -1134,15 +1134,11 @@ cross_validate_globals(struct gl_shader_program *prog,
 
 return;
  }
- /* Only in GLSL ES 3.10, the precision qualifier should not match
-  * between block members defined in matched block names within a
-  * shader interface.
-  *
-  * In GLSL ES 3.00 and ES 3.20, precision qualifier for each block
-  * member should match.
+
+ /* Check the precision qualifier matches for uniform variables. For 
UBOs,
+  * it is checked in link_interface_blocks.cpp.
   */
- if (prog->IsES && (prog->data->Version != 310 ||
-!var->get_interface_type()) &&
+ if (prog->IsES && !var->get_interface_type() &&
  existing->data.precision != var->data.precision) {
 if ((existing->data.used && var->data.used) || prog->data->Version 
>= 300) {
linker_error(prog, "declarations for %s `%s` have "
-- 
2.14.1

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


Re: [Mesa-dev] [PATCH] r600/sb: insert the else clause when we might depart from a loop

2018-01-29 Thread Gert Wollny
Great job, this fixes the piglit, shows no regressions there, and
doesn't add an else branch when it is optimized away. You might want to
add that this fixes shaders@ssa@fs-if-def-else-break and  
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101442

Since the other piglits that fail with sb and pass without it are
differnt issues I'll open separate bugs for these, so that this one can
savely be closes when the patch lands.

Tested-By: Gert Wollny   

Best, 
Gert 

Am Dienstag, den 30.01.2018, 16:40 +1000 schrieb Dave Airlie:
> From: Dave Airlie 
> 
> If there is a break inside the else clause and this means we
> are breaking from a loop, the loop finalise will want to insert
> the LOOP_BREAK/CONTINUE instruction, however if we don't emit
> the else there is no where for these to end up, so they will end
> up in the wrong place.
> 
> Signed-off-by: Dave Airlie 
> ---
>  src/gallium/drivers/r600/sb/sb_bc_finalize.cpp | 17
> +
>  1 file changed, 17 insertions(+)
> 
> diff --git a/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
> b/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
> index 099b295..d3fab80 100644
> --- a/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
> +++ b/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
> @@ -208,8 +208,25 @@ void bc_finalizer::finalize_if(region_node* r) {
>   r->push_front(if_jump);
>   r->push_back(if_pop);
>  
> + /* the depart/repeat 1 is actually part of the
> "else" code.
> +  * if it's a depart for an outer loop region it will
> want to
> +  * insert a LOOP_BREAK or LOOP_CONTINUE in here, so
> we need
> +  * to emit the else clause.
> +  */
>   bool has_else = n_if->next;
>  
> + if (repdep1->is_depart()) {
> + depart_node *dep1 =
> static_cast(repdep1);
> + if (dep1->target != r && dep1->target-
> >is_loop())
> + has_else = true;
> + }
> +
> + if (repdep1->is_repeat()) {
> + repeat_node *rep1 =
> static_cast(repdep1);
> + if (rep1->target != r && rep1->target-
> >is_loop())
> + has_else = true;
> + }
> +
>   if (has_else) {
>   cf_node *nelse = sh.create_cf(CF_OP_ELSE);
>   n_if->insert_after(nelse);
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] r600/sb: insert the else clause when we might depart from a loop

2018-01-29 Thread Dave Airlie
From: Dave Airlie 

If there is a break inside the else clause and this means we
are breaking from a loop, the loop finalise will want to insert
the LOOP_BREAK/CONTINUE instruction, however if we don't emit
the else there is no where for these to end up, so they will end
up in the wrong place.

Signed-off-by: Dave Airlie 
---
 src/gallium/drivers/r600/sb/sb_bc_finalize.cpp | 17 +
 1 file changed, 17 insertions(+)

diff --git a/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp 
b/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
index 099b295..d3fab80 100644
--- a/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
+++ b/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
@@ -208,8 +208,25 @@ void bc_finalizer::finalize_if(region_node* r) {
r->push_front(if_jump);
r->push_back(if_pop);
 
+   /* the depart/repeat 1 is actually part of the "else" code.
+* if it's a depart for an outer loop region it will want to
+* insert a LOOP_BREAK or LOOP_CONTINUE in here, so we need
+* to emit the else clause.
+*/
bool has_else = n_if->next;
 
+   if (repdep1->is_depart()) {
+   depart_node *dep1 = static_cast(repdep1);
+   if (dep1->target != r && dep1->target->is_loop())
+   has_else = true;
+   }
+
+   if (repdep1->is_repeat()) {
+   repeat_node *rep1 = static_cast(repdep1);
+   if (rep1->target != r && rep1->target->is_loop())
+   has_else = true;
+   }
+
if (has_else) {
cf_node *nelse = sh.create_cf(CF_OP_ELSE);
n_if->insert_after(nelse);
-- 
2.9.5

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


Re: [Mesa-dev] [PATCH] ac/llvm: bump the number of results to 8.

2018-01-29 Thread Timothy Arceri

Thanks!

Reviewed-by: Timothy Arceri 

On 30/01/18 14:59, Dave Airlie wrote:

From: Dave Airlie 

This function can get access for a 64-bit dvec4, which means we
have to load 8 components.

This fixes:
R600_DEBUG=nir ./bin/shader_runner 
generated_tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-abs-dvec4.shader_test
 -auto
---
  src/amd/common/ac_llvm_build.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 5e08508..6afe7f9 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -983,7 +983,7 @@ ac_build_buffer_load(struct ac_llvm_context *ctx,
if (allow_smem && !glc && !slc) {
assert(vindex == NULL);
  
-		LLVMValueRef result[4];

+   LLVMValueRef result[8];
  
  		for (int i = 0; i < num_channels; i++) {

if (i) {


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


Re: [Mesa-dev] [PATCH] i965: move disk cache from brw_context to intel_screen

2018-01-29 Thread Jordan Justen
Reviewed-by: Jordan Justen 

On 2018-01-29 04:39:28, Tapani Pälli wrote:
> Now every context refers to same disk_cache instance in screen.
> 
> Signed-off-by: Tapani Pälli 
> Suggested-by: Emil Velikov 
> ---
>  src/mesa/drivers/dri/i965/brw_context.c| 4 +---
>  src/mesa/drivers/dri/i965/brw_disk_cache.c | 6 +++---
>  src/mesa/drivers/dri/i965/brw_state.h  | 2 +-
>  src/mesa/drivers/dri/i965/intel_screen.c   | 5 +
>  src/mesa/drivers/dri/i965/intel_screen.h   | 2 ++
>  5 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
> b/src/mesa/drivers/dri/i965/brw_context.c
> index 07a234b367..addacf2cf8 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -1066,7 +1066,7 @@ brwCreateContext(gl_api api,
> vbo_use_buffer_objects(ctx);
> vbo_always_unmap_buffers(ctx);
>  
> -   brw_disk_cache_init(brw);
> +   brw->ctx.Cache = brw->screen->disk_cache;
>  
> return true;
>  }
> @@ -1130,8 +1130,6 @@ intelDestroyContext(__DRIcontext * driContextPriv)
>  
> driDestroyOptionCache(&brw->optionCache);
>  
> -   disk_cache_destroy(brw->ctx.Cache);
> -
> /* free the Mesa context */
> _mesa_free_context_data(&brw->ctx);
>  
> diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c 
> b/src/mesa/drivers/dri/i965/brw_disk_cache.c
> index 6196386425..f989456bcd 100644
> --- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
> +++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
> @@ -404,7 +404,7 @@ brw_disk_cache_write_compute_program(struct brw_context 
> *brw)
>  }
>  
>  void
> -brw_disk_cache_init(struct brw_context *brw)
> +brw_disk_cache_init(struct intel_screen *screen)
>  {
>  #ifdef ENABLE_SHADER_CACHE
> if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", true))
> @@ -412,7 +412,7 @@ brw_disk_cache_init(struct brw_context *brw)
>  
> char renderer[10];
> MAYBE_UNUSED int len = snprintf(renderer, sizeof(renderer), "i965_%04x",
> -   brw->screen->deviceID);
> +   screen->deviceID);
> assert(len == sizeof(renderer) - 1);
>  
> const struct build_id_note *note =
> @@ -425,6 +425,6 @@ brw_disk_cache_init(struct brw_context *brw)
> char timestamp[41];
> _mesa_sha1_format(timestamp, id_sha1);
>  
> -   brw->ctx.Cache = disk_cache_create(renderer, timestamp, 0);
> +   screen->disk_cache = disk_cache_create(renderer, timestamp, 0);
>  #endif
>  }
> diff --git a/src/mesa/drivers/dri/i965/brw_state.h 
> b/src/mesa/drivers/dri/i965/brw_state.h
> index ad508950f7..d29ae6b972 100644
> --- a/src/mesa/drivers/dri/i965/brw_state.h
> +++ b/src/mesa/drivers/dri/i965/brw_state.h
> @@ -125,7 +125,7 @@ void gen8_write_pma_stall_bits(struct brw_context *brw,
> uint32_t pma_stall_bits);
>  
>  /* brw_disk_cache.c */
> -void brw_disk_cache_init(struct brw_context *brw);
> +void brw_disk_cache_init(struct intel_screen *screen);
>  bool brw_disk_cache_upload_program(struct brw_context *brw,
> gl_shader_stage stage);
>  void brw_disk_cache_write_compute_program(struct brw_context *brw);
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
> b/src/mesa/drivers/dri/i965/intel_screen.c
> index a4e34e9f2c..e1e520bc89 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -41,6 +41,7 @@
>  #include "compiler/nir/nir.h"
>  
>  #include "utils.h"
> +#include "util/disk_cache.h"
>  #include "util/xmlpool.h"
>  
>  static const __DRIconfigOptionsExtension brw_config_options = {
> @@ -1572,6 +1573,8 @@ intelDestroyScreen(__DRIscreen * sPriv)
> brw_bufmgr_destroy(screen->bufmgr);
> driDestroyOptionInfo(&screen->optionCache);
>  
> +   disk_cache_destroy(screen->disk_cache);
> +
> ralloc_free(screen);
> sPriv->driverPrivate = NULL;
>  }
> @@ -2683,6 +2686,8 @@ __DRIconfig **intelInitScreen2(__DRIscreen *dri_screen)
>}
> }
>  
> +   brw_disk_cache_init(screen);
> +
> return (const __DRIconfig**) intel_screen_make_configs(dri_screen);
>  }
>  
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.h 
> b/src/mesa/drivers/dri/i965/intel_screen.h
> index 7948617b7f..ef2d08974e 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.h
> +++ b/src/mesa/drivers/dri/i965/intel_screen.h
> @@ -117,6 +117,8 @@ struct intel_screen
> bool mesa_format_supports_texture[MESA_FORMAT_COUNT];
> bool mesa_format_supports_render[MESA_FORMAT_COUNT];
> enum isl_format mesa_to_isl_render_format[MESA_FORMAT_COUNT];
> +
> +   struct disk_cache *disk_cache;
>  };
>  
>  extern void intelDestroyContext(__DRIcontext * driContextPriv);
> -- 
> 2.14.3
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: Correctly print glTexImage dimensions

2018-01-29 Thread Tapani Pälli



On 01/29/2018 01:36 PM, Elie Tournier wrote:

On Mon, Jan 29, 2018 at 01:24:42PM +0200, Tapani Pälli wrote:



On 01/29/2018 12:05 PM, Elie Tournier wrote:

On Fri, Jan 26, 2018 at 02:34:03PM +0200, Tapani Pälli wrote:

Hi;

On 01/25/2018 05:18 PM, Elie Tournier wrote:

texture_format_error_check_gles() displays error like "glTexImage%dD".
This patch just replace the %d by the correct dimension.

Signed-off-by: Elie Tournier 
---
src/mesa/main/teximage.c | 13 ++---
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index e5f8bb0718..cc329e6410 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1787,7 +1787,6 @@ texture_formats_agree(GLenum internalFormat,
 * \param format pixel data format given by the user.
 * \param type pixel data type given by the user.
 * \param internalFormat internal format given by the user.
- * \param dimensions texture image dimensions (must be 1, 2 or 3).
 * \param callerName name of the caller function to print in the error 
message
 *
 * \return true if a error is found, false otherwise
@@ -1796,8 +1795,7 @@ texture_formats_agree(GLenum internalFormat,
 */
static bool
texture_format_error_check_gles(struct gl_context *ctx, GLenum format,
-GLenum type, GLenum internalFormat,
-GLuint dimensions, const char *callerName)
+GLenum type, GLenum internalFormat, const char 
*callerName)
{
   GLenum err = _mesa_es3_error_check_format_and_type(ctx, format, type,
  internalFormat);
@@ -1911,9 +1909,11 @@ texture_error_check( struct gl_context *ctx,
* Formats and types that require additional extensions (e.g., GL_FLOAT
* requires GL_OES_texture_float) are filtered elsewhere.
*/
+   char bufCallerName[20];
+   snprintf(bufCallerName, 20, "glTexImage%dD", dimensions);


I don't think this is going to work, reason is that this error check is used
both from glTexImage and glTexSubImage. For example _mesa_TexSubImage2D
passes "glTexSubImage2D" as callerName like this:

_mesa_TexSubImage2D
texsubimage_err
texsubimage_error_check
texture_format_error_check_gles


Hello Tapani,

I'm not sure to understand your comment.
This patch just call texture_format_error_check_gles() with callerName 
parameter set correctly.
Previously, callerName was "glTexImage%dD" but we didn't display the dimension.
So I use snprintf in order to print the image dimension.


Sorry, now I noticed this works just fine. I was blind before and thought
you did the snprintf in texture_format_error_check_gles.

Sorry for not being clear the first time.



I should probably split this patch in 2:
* Remove unused "dimensions" parameter in texture_format_error_check_gles.
* Set callerName with the correct dimension.


I'm fine having these on same patch;
Reviewed-by: Tapani Pälli 


Thanks.
Do you mind push this patch? I don't have commit right.


Sure, pushed as 6f8518e068






   if (_mesa_is_gles(ctx) &&
-   texture_format_error_check_gles(ctx, format, type, internalFormat,
-   dimensions, "glTexImage%dD")) {
+   texture_format_error_check_gles(ctx, format, type,
+   internalFormat, bufCallerName)) {
  return GL_TRUE;
   }
@@ -2234,8 +2234,7 @@ texsubimage_error_check(struct gl_context *ctx, GLuint 
dimensions,
*/
   if (_mesa_is_gles(ctx) &&
   texture_format_error_check_gles(ctx, format, type,
-   internalFormat,
-   dimensions, callerName)) {
+   internalFormat, callerName)) {
  return GL_TRUE;
   }


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


Re: [Mesa-dev] [PATCH] r600/sb: Force ELSE path if the byte code started off with it

2018-01-29 Thread Dave Airlie
On 30 Jan. 2018 3:35 pm, "Dave Airlie"  wrote:

On 30 January 2018 at 06:33, Dave Airlie  wrote:
> On 30 January 2018 at 06:25, Gert Wollny  wrote:
>> Am Montag, den 29.01.2018, 20:32 +0100 schrieb Roland Scheidegger:
>>>
>>> Am I correct assuming that for something like
>>>while (foo) {
>>>   if (bar) {
>>>  do something;
>>>   } else {
>>>  /* nothing */
>>>   }
>>>}
>>> The else clause wouldn't get optimized away neither?
>>> (This of course is a trivial example, but I suppose it would extend
>>> to cases where the optimizer actually optimized away the alu
>>> instructions in the else clause).
>>> In this case, this indeed looks rather harsh.
>> This is indeed the case (unless the if is eliminated completely in the
>> if_conversion).
>>
>>> I would have said in theory somehow the break should be some op which
>>> (despite not having a dst) has side-effects so it would not be
>>> subject to elimination somewhere (as there would be a if->next node
>>> in this case then).
>> It is the else that vanishes, but only if there is only a break in the
>> else path, if there there is also an ALU clause, then the else branch
>> is created propperly.
>>
>>> Albeit I'm completely oblivious how it really gets optimized away, is
>>> that based on liveness analysis or something? The sb code is a
>>> mystery to me...
>> I'm trying to understand it, but is is very dificult to grasp how it
>> works even with the debugging output. Well, maybe Dave has a better
>> idea.
>>
>
> I'm reading the paper the whole depart region stuff is based on today,
> maybe I'll come out enlightened or more confused.
>

I'm more confused, but I've attached a patch that I think works, but I'm not
sure it doesn't blow up the world, and I have to head off now.


I think this may need to check repdep1 region is not the same as the
overall region we are processing, or maybe it just needs to check if it's a
loop.

Dave.


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


Re: [Mesa-dev] [PATCH] r600/sb: Force ELSE path if the byte code started off with it

2018-01-29 Thread Dave Airlie
On 30 January 2018 at 06:33, Dave Airlie  wrote:
> On 30 January 2018 at 06:25, Gert Wollny  wrote:
>> Am Montag, den 29.01.2018, 20:32 +0100 schrieb Roland Scheidegger:
>>>
>>> Am I correct assuming that for something like
>>>while (foo) {
>>>   if (bar) {
>>>  do something;
>>>   } else {
>>>  /* nothing */
>>>   }
>>>}
>>> The else clause wouldn't get optimized away neither?
>>> (This of course is a trivial example, but I suppose it would extend
>>> to cases where the optimizer actually optimized away the alu
>>> instructions in the else clause).
>>> In this case, this indeed looks rather harsh.
>> This is indeed the case (unless the if is eliminated completely in the
>> if_conversion).
>>
>>> I would have said in theory somehow the break should be some op which
>>> (despite not having a dst) has side-effects so it would not be
>>> subject to elimination somewhere (as there would be a if->next node
>>> in this case then).
>> It is the else that vanishes, but only if there is only a break in the
>> else path, if there there is also an ALU clause, then the else branch
>> is created propperly.
>>
>>> Albeit I'm completely oblivious how it really gets optimized away, is
>>> that based on liveness analysis or something? The sb code is a
>>> mystery to me...
>> I'm trying to understand it, but is is very dificult to grasp how it
>> works even with the debugging output. Well, maybe Dave has a better
>> idea.
>>
>
> I'm reading the paper the whole depart region stuff is based on today,
> maybe I'll come out enlightened or more confused.
>

I'm more confused, but I've attached a patch that I think works, but I'm not
sure it doesn't blow up the world, and I have to head off now.

Dave.
From 0ffea4924a82d1c23f0bb29076bf359bfbcf1207 Mon Sep 17 00:00:00 2001
From: Dave Airlie 
Date: Tue, 30 Jan 2018 15:34:24 +1000
Subject: [PATCH] sb/hacky patch

---
 src/gallium/drivers/r600/sb/sb_bc_finalize.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp b/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
index 099b295..0e8d7e1 100644
--- a/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
+++ b/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
@@ -208,7 +208,9 @@ void bc_finalizer::finalize_if(region_node* r) {
 		r->push_front(if_jump);
 		r->push_back(if_pop);
 
-		bool has_else = n_if->next;
+		/* if outer node is a depart, we need to have an else
+		   to create the correct flow control */
+		bool has_else = n_if->next || repdep1->is_depart();
 
 		if (has_else) {
 			cf_node *nelse = sh.create_cf(CF_OP_ELSE);
-- 
2.1.0

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


[Mesa-dev] [PATCH] r600: don't do stack workarounds for hemlock

2018-01-29 Thread sroland
From: Roland Scheidegger 

By the looks of it it seems hemlock is treated separately to cypress, but
certainly it won't need the stack workarounds cedar/redwood (and
seemingly every other eg chip except cypress/juniper) need.
(Discovered by accident.)
---
 src/gallium/drivers/r600/sb/sb_bc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/r600/sb/sb_bc.h 
b/src/gallium/drivers/r600/sb/sb_bc.h
index b35671bf0f..a249395474 100644
--- a/src/gallium/drivers/r600/sb/sb_bc.h
+++ b/src/gallium/drivers/r600/sb/sb_bc.h
@@ -665,6 +665,7 @@ public:
return false;
 
switch (hw_chip) {
+   case HW_CHIP_HEMLOCK:
case HW_CHIP_CYPRESS:
case HW_CHIP_JUNIPER:
return false;
-- 
2.12.3

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


Re: [Mesa-dev] [PATCH v2] mesa: enable ASTC/ETC1 compressed 3D textures

2018-01-29 Thread Eric Anholt
"Juan A. Suarez Romero"  writes:

> Enable these kind of 3D texture when proper extensions are available.
>
> Fixes KHR-GLES2.texture_3d.* with these textures.
>
> v2: add better clarification (Eric)
> ---
>  src/mesa/main/teximage.c | 31 ---
>  1 file changed, 24 insertions(+), 7 deletions(-)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index e5f8bb0718f..56235898c66 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -1487,6 +1487,9 @@ _mesa_target_can_be_compressed(const struct gl_context 
> *ctx, GLenum target,
>break;
> case GL_TEXTURE_3D:
>switch (layout) {
> +  case MESA_FORMAT_LAYOUT_ETC1:
> + target_can_be_compresed = 
> ctx->Extensions.OES_compressed_ETC1_RGB8_texture;
> + break;
>case MESA_FORMAT_LAYOUT_ETC2:
>   /* See ETC2/EAC comment in case GL_TEXTURE_CUBE_MAP_ARRAY. */

OK, I took a look at the ETC2/EAC comment above, this time, and it looks
like 3D textures are supposed to be not supported with ETC2 or ASTC
according to table 8.17 in GLES 3.2.

This is looking more like a testcase bug to me.


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


[Mesa-dev] [Bug 104803] SIGSEGV in state_tracker/st_glsl_to_tgsi_temprename.cpp

2018-01-29 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=104803

Brian Paul  changed:

   What|Removed |Added

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

--- Comment #8 from Brian Paul  ---
Fixed with commit 6a7d1ca2c49ae06bbb323936f1e1c17ba7e2c9a1

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


[Mesa-dev] [PATCH] ac/llvm: bump the number of results to 8.

2018-01-29 Thread Dave Airlie
From: Dave Airlie 

This function can get access for a 64-bit dvec4, which means we
have to load 8 components.

This fixes:
R600_DEBUG=nir ./bin/shader_runner 
generated_tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-abs-dvec4.shader_test
 -auto
---
 src/amd/common/ac_llvm_build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 5e08508..6afe7f9 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -983,7 +983,7 @@ ac_build_buffer_load(struct ac_llvm_context *ctx,
if (allow_smem && !glc && !slc) {
assert(vindex == NULL);
 
-   LLVMValueRef result[4];
+   LLVMValueRef result[8];
 
for (int i = 0; i < num_channels; i++) {
if (i) {
-- 
2.9.5

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


[Mesa-dev] [PATCH v2 12/12] st/glsl_to_nir: disable io lowering and array splitting of fs inputs

2018-01-29 Thread Timothy Arceri
We need this to be able to support the interpolateAt builtins in a
sane way. It also leads to the generation of more optimal code.

The lowering and splitting is made conditional on lower_all_io_to_temps
because vc4 and freedreno both expect these passes to be enabled and
niether support glsl 400 so don't need to deal with the interpolateAt
builtins.

We leave the other stages for now as to avoid regressions. Ideally we
could remove the stage checks and just set the nir options correctly
for each stage. However all gallium drivers currently just use return
the same nir compiler options for all stages, and it's probably more
trouble than its worth to change this.
---
 src/mesa/state_tracker/st_glsl_to_nir.cpp | 22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index a3d447c5a4..65931bfa33 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -451,6 +451,8 @@ st_nir_get_mesa_program(struct gl_context *ctx,
 struct gl_linked_shader *shader)
 {
struct st_context *st = st_context(ctx);
+   const nir_shader_compiler_options *options =
+  ctx->Const.ShaderCompilerOptions[shader->Program->info.stage].NirOptions;
struct gl_program *prog;
 
validate_ir_tree(shader->ir);
@@ -480,12 +482,18 @@ st_nir_get_mesa_program(struct gl_context *ctx,
set_st_program(prog, shader_program, nir);
prog->nir = nir;
 
-   if (nir->info.stage != MESA_SHADER_TESS_CTRL &&
-   nir->info.stage != MESA_SHADER_TESS_EVAL) {
+   if (options->lower_all_io_to_temps ||
+   nir->info.stage == MESA_SHADER_VERTEX ||
+   nir->info.stage == MESA_SHADER_GEOMETRY) {
   NIR_PASS_V(nir, nir_lower_io_to_temporaries,
  nir_shader_get_entrypoint(nir),
  true, true);
+   } else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
+  NIR_PASS_V(nir, nir_lower_io_to_temporaries,
+ nir_shader_get_entrypoint(nir),
+ true, false);
}
+
NIR_PASS_V(nir, nir_lower_global_vars_to_local);
NIR_PASS_V(nir, nir_split_var_copies);
NIR_PASS_V(nir, nir_lower_var_copies);
@@ -655,12 +663,18 @@ st_finalize_nir(struct st_context *st, struct gl_program 
*prog,
 struct gl_shader_program *shader_program, nir_shader *nir)
 {
struct pipe_screen *screen = st->pipe->screen;
+   const nir_shader_compiler_options *options =
+  st->ctx->Const.ShaderCompilerOptions[prog->info.stage].NirOptions;
 
NIR_PASS_V(nir, nir_split_var_copies);
NIR_PASS_V(nir, nir_lower_var_copies);
-   if (nir->info.stage != MESA_SHADER_TESS_CTRL &&
-   nir->info.stage != MESA_SHADER_TESS_EVAL)
+   if (options->lower_all_io_to_temps ||
+   nir->info.stage == MESA_SHADER_VERTEX ||
+   nir->info.stage == MESA_SHADER_GEOMETRY) {
   NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, false);
+   } else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
+  NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, true);
+   }
 
if (nir->info.stage == MESA_SHADER_VERTEX) {
   /* Needs special handling so drvloc matches the vbo state: */
-- 
2.14.3

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


[Mesa-dev] [PATCH v2 10/12] nir/st_glsl_to_nir: add param to disable splitting of inputs

2018-01-29 Thread Timothy Arceri
We need this because we will always copy fs outputs to temps and
split the arrays, but do not want to do either of these with fs
inputs as it is unnessisary and makes handling interpolateAt
builtins difficult.
---
 src/compiler/nir/nir.h |  3 ++-
 src/compiler/nir/nir_lower_io_arrays_to_elements.c | 22 +-
 src/mesa/state_tracker/st_glsl_to_nir.cpp  |  2 +-
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 4bb96c3c95..86d1c68fa7 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2522,7 +2522,8 @@ bool nir_lower_load_const_to_scalar(nir_shader *shader);
 bool nir_lower_read_invocation_to_scalar(nir_shader *shader);
 bool nir_lower_phis_to_scalar(nir_shader *shader);
 void nir_lower_io_arrays_to_elements(nir_shader *producer, nir_shader 
*consumer);
-void nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader);
+void nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader,
+  bool outputs_only);
 void nir_lower_io_to_scalar(nir_shader *shader, nir_variable_mode mask);
 void nir_lower_io_to_scalar_early(nir_shader *shader, nir_variable_mode mask);
 
diff --git a/src/compiler/nir/nir_lower_io_arrays_to_elements.c 
b/src/compiler/nir/nir_lower_io_arrays_to_elements.c
index cdf9a76a88..9a5eec8f87 100644
--- a/src/compiler/nir/nir_lower_io_arrays_to_elements.c
+++ b/src/compiler/nir/nir_lower_io_arrays_to_elements.c
@@ -346,7 +346,8 @@ lower_io_arrays_to_elements(nir_shader *shader, 
nir_variable_mode mask,
 }
 
 void
-nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader)
+nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader,
+ bool outputs_only)
 {
struct hash_table *split_inputs =
   _mesa_hash_table_create(NULL, _mesa_hash_pointer,
@@ -360,19 +361,22 @@ nir_lower_io_arrays_to_elements_no_indirects(nir_shader 
*shader)
lower_io_arrays_to_elements(shader, nir_var_shader_out, indirects,
patch_indirects, split_outputs, true);
 
-   lower_io_arrays_to_elements(shader, nir_var_shader_in, indirects,
-   patch_indirects, split_inputs, true);
+   if (!outputs_only) {
+  lower_io_arrays_to_elements(shader, nir_var_shader_in, indirects,
+  patch_indirects, split_inputs, true);
 
-   /* Remove old input from the shaders inputs list */
-   struct hash_entry *entry;
-   hash_table_foreach(split_inputs, entry) {
-  nir_variable *var = (nir_variable *) entry->key;
-  exec_node_remove(&var->node);
+  /* Remove old input from the shaders inputs list */
+  struct hash_entry *entry;
+  hash_table_foreach(split_inputs, entry) {
+ nir_variable *var = (nir_variable *) entry->key;
+ exec_node_remove(&var->node);
 
-  free(entry->data);
+ free(entry->data);
+  }
}
 
/* Remove old output from the shaders outputs list */
+   struct hash_entry *entry;
hash_table_foreach(split_outputs, entry) {
   nir_variable *var = (nir_variable *) entry->key;
   exec_node_remove(&var->node);
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 6d3a7c78dc..a3d447c5a4 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -660,7 +660,7 @@ st_finalize_nir(struct st_context *st, struct gl_program 
*prog,
NIR_PASS_V(nir, nir_lower_var_copies);
if (nir->info.stage != MESA_SHADER_TESS_CTRL &&
nir->info.stage != MESA_SHADER_TESS_EVAL)
-  NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects);
+  NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, false);
 
if (nir->info.stage == MESA_SHADER_VERTEX) {
   /* Needs special handling so drvloc matches the vbo state: */
-- 
2.14.3

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


[Mesa-dev] [PATCH v2 09/12] st/glsl_to_nir: copy nir compiler options to context

2018-01-29 Thread Timothy Arceri
Various nir passes may expect this to be here as does the nir
serialisation pass.
---
 src/mesa/state_tracker/st_extensions.c| 17 +
 src/mesa/state_tracker/st_glsl_to_nir.cpp | 10 ++
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index d00ee83c05..ea77aa6ed1 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -26,6 +26,8 @@
  * 
  **/
 
+#include "compiler/nir/nir.h"
+
 #include "main/imports.h"
 #include "main/context.h"
 #include "main/macros.h"
@@ -156,31 +158,46 @@ void st_init_limits(struct pipe_screen *screen,
for (sh = 0; sh < PIPE_SHADER_TYPES; ++sh) {
   struct gl_shader_compiler_options *options;
   struct gl_program_constants *pc;
+  const nir_shader_compiler_options *nir_options =
+ (const nir_shader_compiler_options *)
+screen->get_compiler_options(screen, PIPE_SHADER_IR_NIR, sh);
 
   switch (sh) {
   case PIPE_SHADER_FRAGMENT:
  pc = &c->Program[MESA_SHADER_FRAGMENT];
  options = &c->ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
+ c->ShaderCompilerOptions[MESA_SHADER_FRAGMENT].NirOptions =
+nir_options;
  break;
   case PIPE_SHADER_VERTEX:
  pc = &c->Program[MESA_SHADER_VERTEX];
  options = &c->ShaderCompilerOptions[MESA_SHADER_VERTEX];
+ c->ShaderCompilerOptions[MESA_SHADER_VERTEX].NirOptions =
+nir_options;
  break;
   case PIPE_SHADER_GEOMETRY:
  pc = &c->Program[MESA_SHADER_GEOMETRY];
  options = &c->ShaderCompilerOptions[MESA_SHADER_GEOMETRY];
+ c->ShaderCompilerOptions[MESA_SHADER_GEOMETRY].NirOptions =
+nir_options;
  break;
   case PIPE_SHADER_TESS_CTRL:
  pc = &c->Program[MESA_SHADER_TESS_CTRL];
  options = &c->ShaderCompilerOptions[MESA_SHADER_TESS_CTRL];
+ c->ShaderCompilerOptions[MESA_SHADER_TESS_CTRL].NirOptions =
+nir_options;
  break;
   case PIPE_SHADER_TESS_EVAL:
  pc = &c->Program[MESA_SHADER_TESS_EVAL];
  options = &c->ShaderCompilerOptions[MESA_SHADER_TESS_EVAL];
+ c->ShaderCompilerOptions[MESA_SHADER_TESS_EVAL].NirOptions =
+nir_options;
  break;
   case PIPE_SHADER_COMPUTE:
  pc = &c->Program[MESA_SHADER_COMPUTE];
  options = &c->ShaderCompilerOptions[MESA_SHADER_COMPUTE];
+ c->ShaderCompilerOptions[MESA_SHADER_COMPUTE].NirOptions =
+nir_options;
 
  if (!screen->get_param(screen, PIPE_CAP_COMPUTE))
 continue;
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 8639544142..6d3a7c78dc 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -304,14 +304,8 @@ st_glsl_to_nir(struct st_context *st, struct gl_program 
*prog,
struct gl_shader_program *shader_program,
gl_shader_stage stage)
 {
-   struct pipe_screen *pscreen = st->pipe->screen;
-   enum pipe_shader_type ptarget = pipe_shader_type_from_mesa(stage);
-   const nir_shader_compiler_options *options;
-
-   assert(pscreen->get_compiler_options);   /* drivers using NIR must 
implement this */
-
-   options = (const nir_shader_compiler_options *)
-  pscreen->get_compiler_options(pscreen, PIPE_SHADER_IR_NIR, ptarget);
+   const nir_shader_compiler_options *options =
+  st->ctx->Const.ShaderCompilerOptions[prog->info.stage].NirOptions;
assert(options);
 
if (prog->nir)
-- 
2.14.3

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


[Mesa-dev] [PATCH v2 11/12] nir: add lower_all_io_to_temps flag

2018-01-29 Thread Timothy Arceri
This will be used for freedreno and vc4 which require all inputs
and outputs to be copied to temps.
---
 src/broadcom/compiler/nir_to_vir.c  | 1 +
 src/compiler/nir/nir.h  | 2 ++
 src/gallium/drivers/freedreno/ir3/ir3_nir.c | 1 +
 src/gallium/drivers/vc4/vc4_program.c   | 1 +
 4 files changed, 5 insertions(+)

diff --git a/src/broadcom/compiler/nir_to_vir.c 
b/src/broadcom/compiler/nir_to_vir.c
index 46f3c9bc41..0e2e8e2daa 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -1874,6 +1874,7 @@ nir_to_vir(struct v3d_compile *c)
 }
 
 const nir_shader_compiler_options v3d_nir_options = {
+.lower_all_io_to_temps = true,
 .lower_extract_byte = true,
 .lower_extract_word = true,
 .lower_bitfield_insert = true,
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 86d1c68fa7..9ab2769e06 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1873,6 +1873,8 @@ typedef struct nir_shader_compiler_options {
bool lower_extract_byte;
bool lower_extract_word;
 
+   bool lower_all_io_to_temps;
+
/**
 * Does the driver support real 32-bit integers?  (Otherwise, integers
 * are simulated by floats.)
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir.c 
b/src/gallium/drivers/freedreno/ir3/ir3_nir.c
index 9ab5e0f7f2..2393306e19 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_nir.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_nir.c
@@ -50,6 +50,7 @@ static const nir_shader_compiler_options options = {
.vertex_id_zero_based = true,
.lower_extract_byte = true,
.lower_extract_word = true,
+   .lower_all_io_to_temps = true,
 };
 
 struct nir_shader *
diff --git a/src/gallium/drivers/vc4/vc4_program.c 
b/src/gallium/drivers/vc4/vc4_program.c
index 98cdfdf33e..706982c4a1 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -2180,6 +2180,7 @@ nir_to_qir(struct vc4_compile *c)
 }
 
 static const nir_shader_compiler_options nir_options = {
+.lower_all_io_to_temps = true,
 .lower_extract_byte = true,
 .lower_extract_word = true,
 .lower_ffma = true,
-- 
2.14.3

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


[Mesa-dev] [PATCH v2 08/12] radeonsi/nir: add input support for arrays that have not been copied to temps and split

2018-01-29 Thread Timothy Arceri
We need this to be able to support the interpolateAt builtins in a
sane way. It also leads to the generation of more optimal code.

Reviewed-by: Marek Olšák 
---
 src/gallium/drivers/radeonsi/si_shader_nir.c | 146 +++
 1 file changed, 79 insertions(+), 67 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c 
b/src/gallium/drivers/radeonsi/si_shader_nir.c
index b6aa79857a..128be585cd 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -266,7 +266,14 @@ void si_nir_scan_shader(const struct nir_shader *nir,
unsigned num_inputs = 0;
nir_foreach_variable(variable, &nir->inputs) {
unsigned semantic_name, semantic_index;
-   unsigned attrib_count = 
glsl_count_attribute_slots(variable->type,
+
+   const struct glsl_type *type = variable->type;
+   if (nir_is_per_vertex_io(variable, nir->info.stage)) {
+   assert(glsl_type_is_array(type));
+   type = glsl_get_array_element(type);
+   }
+
+   unsigned attrib_count = glsl_count_attribute_slots(type,
   
nir->info.stage == MESA_SHADER_VERTEX);
 
/* Vertex shader inputs don't have semantics. The state
@@ -281,9 +288,6 @@ void si_nir_scan_shader(const struct nir_shader *nir,
continue;
}
 
-   assert(nir->info.stage != MESA_SHADER_FRAGMENT ||
-  (attrib_count == 1 && "not implemented"));
-
/* Fragment shader position is a system value. */
if (nir->info.stage == MESA_SHADER_FRAGMENT &&
variable->data.location == VARYING_SLOT_POS) {
@@ -296,66 +300,70 @@ void si_nir_scan_shader(const struct nir_shader *nir,
}
 
i = variable->data.driver_location;
-   if (processed_inputs & ((uint64_t)1 << i))
-   continue;
 
-   processed_inputs |= ((uint64_t)1 << i);
-   num_inputs++;
+   for (unsigned j = 0; j < attrib_count; j++, i++) {
 
-   tgsi_get_gl_varying_semantic(variable->data.location, true,
-&semantic_name, &semantic_index);
+   if (processed_inputs & ((uint64_t)1 << i))
+   continue;
 
-   info->input_semantic_name[i] = semantic_name;
-   info->input_semantic_index[i] = semantic_index;
+   processed_inputs |= ((uint64_t)1 << i);
+   num_inputs++;
 
-   if (semantic_name == TGSI_SEMANTIC_PRIMID)
-   info->uses_primid = true;
+   tgsi_get_gl_varying_semantic(variable->data.location + 
j, true,
+&semantic_name, 
&semantic_index);
 
-   if (variable->data.sample)
-   info->input_interpolate_loc[i] = 
TGSI_INTERPOLATE_LOC_SAMPLE;
-   else if (variable->data.centroid)
-   info->input_interpolate_loc[i] = 
TGSI_INTERPOLATE_LOC_CENTROID;
-   else
-   info->input_interpolate_loc[i] = 
TGSI_INTERPOLATE_LOC_CENTER;
+   info->input_semantic_name[i] = semantic_name;
+   info->input_semantic_index[i] = semantic_index;
 
-   enum glsl_base_type base_type =
-   glsl_get_base_type(glsl_without_array(variable->type));
+   if (semantic_name == TGSI_SEMANTIC_PRIMID)
+   info->uses_primid = true;
 
-   switch (variable->data.interpolation) {
-   case INTERP_MODE_NONE:
-   if (glsl_base_type_is_integer(base_type)) {
-   info->input_interpolate[i] = 
TGSI_INTERPOLATE_CONSTANT;
-   break;
-   }
+   if (variable->data.sample)
+   info->input_interpolate_loc[i] = 
TGSI_INTERPOLATE_LOC_SAMPLE;
+   else if (variable->data.centroid)
+   info->input_interpolate_loc[i] = 
TGSI_INTERPOLATE_LOC_CENTROID;
+   else
+   info->input_interpolate_loc[i] = 
TGSI_INTERPOLATE_LOC_CENTER;
 
-   if (semantic_name == TGSI_SEMANTIC_COLOR) {
-   info->input_interpolate[i] = 
TGSI_INTERPOLATE_COLOR;
-   break;
-   }
-   /* fall-through */
+   enum glsl_base_type base_type =
+   
glsl_get_base_type(glsl_without_array(variable->type));
 
-   case INTERP_MODE_SMOOTH:
- 

[Mesa-dev] [PATCH v2 07/12] ac/radeonsi: add lookup_interp_param and load_sample_position to the abi

2018-01-29 Thread Timothy Arceri
The will enable the interpolateAt builtins to work on the radeonsi
nir backend.

Reviewed-by: Marek Olšák 
---
 src/amd/common/ac_nir_to_llvm.c  | 64 +---
 src/amd/common/ac_shader_abi.h   |  7 
 src/gallium/drivers/radeonsi/si_shader.c |  2 +
 3 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index e4963dc359..fd5989389b 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -3975,9 +3975,11 @@ static LLVMValueRef visit_var_atomic(struct 
nir_to_llvm_context *ctx,
return result;
 }
 
-static LLVMValueRef lookup_interp_param(struct nir_to_llvm_context *ctx,
+static LLVMValueRef lookup_interp_param(struct ac_shader_abi *abi,
enum glsl_interp_mode interp, unsigned 
location)
 {
+   struct nir_to_llvm_context *ctx = nir_to_llvm_context_from_abi(abi);
+
switch (interp) {
case INTERP_MODE_FLAT:
default:
@@ -4003,9 +4005,11 @@ static LLVMValueRef lookup_interp_param(struct 
nir_to_llvm_context *ctx,
return NULL;
 }
 
-static LLVMValueRef load_sample_position(struct nir_to_llvm_context *ctx,
+static LLVMValueRef load_sample_position(struct ac_shader_abi *abi,
 LLVMValueRef sample_id)
 {
+   struct nir_to_llvm_context *ctx = nir_to_llvm_context_from_abi(abi);
+
LLVMValueRef result;
LLVMValueRef ptr = ac_build_gep0(&ctx->ac, ctx->ring_offsets, 
LLVMConstInt(ctx->ac.i32, RING_PS_SAMPLE_POSITIONS, false));
 
@@ -4051,7 +4055,7 @@ static LLVMValueRef load_sample_mask_in(struct 
ac_nir_context *ctx)
return result;
 }
 
-static LLVMValueRef visit_interp(struct nir_to_llvm_context *ctx,
+static LLVMValueRef visit_interp(struct ac_nir_context *ctx,
 const nir_intrinsic_instr *instr)
 {
LLVMValueRef result[4];
@@ -4069,33 +4073,33 @@ static LLVMValueRef visit_interp(struct 
nir_to_llvm_context *ctx,
case nir_intrinsic_interp_var_at_sample:
case nir_intrinsic_interp_var_at_offset:
location = INTERP_CENTER;
-   src0 = get_src(ctx->nir, instr->src[0]);
+   src0 = get_src(ctx, instr->src[0]);
break;
default:
break;
}
 
if (instr->intrinsic == nir_intrinsic_interp_var_at_offset) {
-   src_c0 = ac_to_float(&ctx->ac, 
LLVMBuildExtractElement(ctx->builder, src0, ctx->ac.i32_0, ""));
-   src_c1 = ac_to_float(&ctx->ac, 
LLVMBuildExtractElement(ctx->builder, src0, ctx->ac.i32_1, ""));
+   src_c0 = ac_to_float(&ctx->ac, 
LLVMBuildExtractElement(ctx->ac.builder, src0, ctx->ac.i32_0, ""));
+   src_c1 = ac_to_float(&ctx->ac, 
LLVMBuildExtractElement(ctx->ac.builder, src0, ctx->ac.i32_1, ""));
} else if (instr->intrinsic == nir_intrinsic_interp_var_at_sample) {
LLVMValueRef sample_position;
LLVMValueRef halfval = LLVMConstReal(ctx->ac.f32, 0.5f);
 
/* fetch sample ID */
-   sample_position = load_sample_position(ctx, src0);
+   sample_position = ctx->abi->load_sample_position(ctx->abi, 
src0);
 
-   src_c0 = LLVMBuildExtractElement(ctx->builder, sample_position, 
ctx->ac.i32_0, "");
-   src_c0 = LLVMBuildFSub(ctx->builder, src_c0, halfval, "");
-   src_c1 = LLVMBuildExtractElement(ctx->builder, sample_position, 
ctx->ac.i32_1, "");
-   src_c1 = LLVMBuildFSub(ctx->builder, src_c1, halfval, "");
+   src_c0 = LLVMBuildExtractElement(ctx->ac.builder, 
sample_position, ctx->ac.i32_0, "");
+   src_c0 = LLVMBuildFSub(ctx->ac.builder, src_c0, halfval, "");
+   src_c1 = LLVMBuildExtractElement(ctx->ac.builder, 
sample_position, ctx->ac.i32_1, "");
+   src_c1 = LLVMBuildFSub(ctx->ac.builder, src_c1, halfval, "");
}
-   interp_param = lookup_interp_param(ctx, 
instr->variables[0]->var->data.interpolation, location);
+   interp_param = ctx->abi->lookup_interp_param(ctx->abi, 
instr->variables[0]->var->data.interpolation, location);
attr_number = LLVMConstInt(ctx->ac.i32, input_index, false);
 
if (location == INTERP_CENTER) {
LLVMValueRef ij_out[2];
-   LLVMValueRef ddxy_out = emit_ddxy_interp(ctx->nir, 
interp_param);
+   LLVMValueRef ddxy_out = emit_ddxy_interp(ctx, interp_param);
 
/*
 * take the I then J parameters, and the DDX/Y for it, and
@@ -4108,24 +4112,24 @@ static LLVMValueRef visit_interp(struct 
nir_to_llvm_context *ctx,
for (unsigned i = 0; i < 2; i++) {
LLVMValueRef ix_ll = LLVMConstInt(ctx->ac.i32, i, 
false);
LLVMValueRef iy_ll = LLVMConstInt(ctx->ac.i32, i + 2, 
false);
- 

[Mesa-dev] [PATCH v2 06/12] radeonsi/nir: add prim_mask to the abi

2018-01-29 Thread Timothy Arceri
Reviewed-by: Marek Olšák 
---
 src/amd/common/ac_nir_to_llvm.c  | 11 +--
 src/amd/common/ac_shader_abi.h   |  1 +
 src/gallium/drivers/radeonsi/si_shader.c |  7 ---
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index bcacd4953f..e4963dc359 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -123,7 +123,6 @@ struct nir_to_llvm_context {
LLVMValueRef hs_ring_tess_offchip;
LLVMValueRef hs_ring_tess_factor;
 
-   LLVMValueRef prim_mask;
LLVMValueRef sample_pos_offset;
LLVMValueRef persp_sample, persp_center, persp_centroid;
LLVMValueRef linear_sample, linear_center, linear_centroid;
@@ -1005,7 +1004,7 @@ static void create_function(struct nir_to_llvm_context 
*ctx,
add_arg(&args, ARG_SGPR, ctx->ac.i32,
&ctx->sample_pos_offset);
 
-   add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->prim_mask);
+   add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->abi.prim_mask);
add_arg(&args, ARG_VGPR, ctx->ac.v2i32, &ctx->persp_sample);
add_arg(&args, ARG_VGPR, ctx->ac.v2i32, &ctx->persp_center);
add_arg(&args, ARG_VGPR, ctx->ac.v2i32, &ctx->persp_centroid);
@@ -4146,12 +4145,12 @@ static LLVMValueRef visit_interp(struct 
nir_to_llvm_context *ctx,
 
result[chan] = ac_build_fs_interp(&ctx->ac,
  llvm_chan, 
attr_number,
- ctx->prim_mask, i, j);
+ ctx->abi.prim_mask, 
i, j);
} else {
result[chan] = ac_build_fs_interp_mov(&ctx->ac,
  
LLVMConstInt(ctx->ac.i32, 2, false),
  llvm_chan, 
attr_number,
- ctx->prim_mask);
+ 
ctx->abi.prim_mask);
}
}
return ac_build_varying_gather_values(&ctx->ac, result, 
instr->num_components,
@@ -5464,7 +5463,7 @@ prepare_interp_optimize(struct nir_to_llvm_context *ctx,
}
 
if (uses_center && uses_centroid) {
-   LLVMValueRef sel = LLVMBuildICmp(ctx->builder, LLVMIntSLT, 
ctx->prim_mask, ctx->ac.i32_0, "");
+   LLVMValueRef sel = LLVMBuildICmp(ctx->builder, LLVMIntSLT, 
ctx->abi.prim_mask, ctx->ac.i32_0, "");
ctx->persp_centroid = LLVMBuildSelect(ctx->builder, sel, 
ctx->persp_center, ctx->persp_centroid, "");
ctx->linear_centroid = LLVMBuildSelect(ctx->builder, sel, 
ctx->linear_center, ctx->linear_centroid, "");
}
@@ -5495,7 +5494,7 @@ handle_fs_inputs(struct nir_to_llvm_context *ctx,
if (i >= VARYING_SLOT_VAR0 || i == VARYING_SLOT_PNTC ||
i == VARYING_SLOT_PRIMITIVE_ID || i == VARYING_SLOT_LAYER) {
interp_param = *inputs;
-   interp_fs_input(ctx, index, interp_param, 
ctx->prim_mask,
+   interp_fs_input(ctx, index, interp_param, 
ctx->abi.prim_mask,
inputs);
 
if (!interp_param)
diff --git a/src/amd/common/ac_shader_abi.h b/src/amd/common/ac_shader_abi.h
index 409b49a6cd..9cdfd9d1df 100644
--- a/src/amd/common/ac_shader_abi.h
+++ b/src/amd/common/ac_shader_abi.h
@@ -53,6 +53,7 @@ struct ac_shader_abi {
LLVMValueRef front_face;
LLVMValueRef ancillary;
LLVMValueRef sample_coverage;
+   LLVMValueRef prim_mask;
 
/* For VS and PS: pre-loaded shader inputs.
 *
diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 71a8733780..dfec070d33 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1848,7 +1848,7 @@ void si_llvm_load_input_fs(
interp_fs_input(ctx, input_index, semantic_name,
semantic_index, 0, /* this param is unused */
shader->selector->info.colors_read, interp_param,
-   LLVMGetParam(main_fn, SI_PARAM_PRIM_MASK),
+   ctx->abi.prim_mask,
LLVMGetParam(main_fn, SI_PARAM_FRONT_FACE),
&out[0]);
 }
@@ -4076,7 +4076,7 @@ static void build_interp_intrinsic(const struct 
lp_build_tgsi_action *action,
int input_base, input_array_size;
int chan;
int i;
-   LLVMValueRef prim_mask = LLVMGetParam(ctx->main_fn, SI_PARAM_PRIM_MASK);
+   LLVMValueRef prim_mask = ctx->abi.prim_mask;
LLVMValueRef array_idx;
int interp_param_idx;
unsigne

[Mesa-dev] [PATCH v2 05/12] radeonsi/nir: adjust load_sample_position() to be shared between backends

2018-01-29 Thread Timothy Arceri
With this interface change it can be shared between the tgsi and
nir backends.
---
 src/gallium/drivers/radeonsi/si_shader.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index b18b4f63b8..71a8733780 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1879,8 +1879,9 @@ static LLVMValueRef buffer_load_const(struct 
si_shader_context *ctx,
0, 0, 0, true, true);
 }
 
-static LLVMValueRef load_sample_position(struct si_shader_context *ctx, 
LLVMValueRef sample_id)
+static LLVMValueRef load_sample_position(struct ac_shader_abi *abi, 
LLVMValueRef sample_id)
 {
+   struct si_shader_context *ctx = si_shader_context_from_abi(abi);
struct lp_build_context *uint_bld = &ctx->bld_base.uint_bld;
LLVMValueRef desc = LLVMGetParam(ctx->main_fn, ctx->param_rw_buffers);
LLVMValueRef buf_index = LLVMConstInt(ctx->i32, 
SI_PS_CONST_SAMPLE_POSITIONS, 0);
@@ -4046,7 +4047,7 @@ static void interp_fetch_args(
 
sample_position = lp_build_gather_values(&ctx->gallivm, 
center, 4);
} else {
-   sample_position = load_sample_position(ctx, sample_id);
+   sample_position = load_sample_position(&ctx->abi, 
sample_id);
}
 
emit_data->args[0] = LLVMBuildExtractElement(ctx->ac.builder,
-- 
2.14.3

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


[Mesa-dev] [PATCH v2 04/12] radeonsi/nir: add si_nir_lookup_interp_param() helper

2018-01-29 Thread Timothy Arceri
Reviewed-by: Marek Olšák 
---
 src/amd/common/ac_shader_abi.h|  2 ++
 src/gallium/drivers/radeonsi/si_shader_internal.h |  4 +++
 src/gallium/drivers/radeonsi/si_shader_nir.c  | 36 +++
 3 files changed, 42 insertions(+)

diff --git a/src/amd/common/ac_shader_abi.h b/src/amd/common/ac_shader_abi.h
index 3aab3bf95b..409b49a6cd 100644
--- a/src/amd/common/ac_shader_abi.h
+++ b/src/amd/common/ac_shader_abi.h
@@ -26,6 +26,8 @@
 
 #include 
 
+#include "compiler/shader_enums.h"
+
 enum ac_descriptor_type {
AC_DESC_IMAGE,
AC_DESC_FMASK,
diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h 
b/src/gallium/drivers/radeonsi/si_shader_internal.h
index 3084d88fad..489c468f03 100644
--- a/src/gallium/drivers/radeonsi/si_shader_internal.h
+++ b/src/gallium/drivers/radeonsi/si_shader_internal.h
@@ -292,6 +292,10 @@ LLVMValueRef si_llvm_load_input_gs(struct ac_shader_abi 
*abi,
   LLVMTypeRef type,
   unsigned swizzle);
 
+LLVMValueRef si_nir_lookup_interp_param(struct ac_shader_abi *abi,
+   enum glsl_interp_mode interp,
+   unsigned location);
+
 void si_llvm_emit_store(struct lp_build_tgsi_context *bld_base,
const struct tgsi_full_instruction *inst,
const struct tgsi_opcode_info *info,
diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c 
b/src/gallium/drivers/radeonsi/si_shader_nir.c
index e055164dd4..b6aa79857a 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -648,6 +648,42 @@ LLVMValueRef si_nir_load_input_gs(struct ac_shader_abi 
*abi,
return ac_build_varying_gather_values(&ctx->ac, value, num_components, 
component);
 }
 
+LLVMValueRef
+si_nir_lookup_interp_param(struct ac_shader_abi *abi,
+  enum glsl_interp_mode interp, unsigned location)
+{
+   struct si_shader_context *ctx = si_shader_context_from_abi(abi);
+   int interp_param_idx = -1;
+
+   switch (interp) {
+   case INTERP_MODE_FLAT:
+   return NULL;
+   case INTERP_MODE_SMOOTH:
+   case INTERP_MODE_NONE:
+   if (location == INTERP_CENTER)
+   interp_param_idx = SI_PARAM_PERSP_CENTER;
+   else if (location == INTERP_CENTROID)
+   interp_param_idx = SI_PARAM_PERSP_CENTROID;
+   else if (location == INTERP_SAMPLE)
+   interp_param_idx = SI_PARAM_PERSP_SAMPLE;
+   break;
+   case INTERP_MODE_NOPERSPECTIVE:
+   if (location == INTERP_CENTER)
+   interp_param_idx = SI_PARAM_LINEAR_CENTER;
+   else if (location == INTERP_CENTROID)
+   interp_param_idx = SI_PARAM_LINEAR_CENTROID;
+   else if (location == INTERP_SAMPLE)
+   interp_param_idx = SI_PARAM_LINEAR_SAMPLE;
+   break;
+   default:
+   assert(!"Unhandled interpolation mode.");
+   return NULL;
+   }
+
+   return interp_param_idx != -1 ?
+   LLVMGetParam(ctx->main_fn, interp_param_idx) : NULL;
+}
+
 static LLVMValueRef
 si_nir_load_sampler_desc(struct ac_shader_abi *abi,
 unsigned descriptor_set, unsigned base_index,
-- 
2.14.3

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


[Mesa-dev] [PATCH v2 02/12] radeonsi/nir: move the interpolation qualifier scanning

2018-01-29 Thread Timothy Arceri
We need to collect this when scanning over the instruction rather
than when scanning over the inputs otherwise we might get confliting
values for inputs that are use by the interpolateAt* builtins.

Reviewed-by: Marek Olšák 
---
 src/gallium/drivers/radeonsi/si_shader_nir.c | 52 +++-
 1 file changed, 36 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c 
b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 6368b71206..e055164dd4 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -127,6 +127,40 @@ static void scan_instruction(struct tgsi_shader_info *info,
case nir_intrinsic_ssbo_atomic_comp_swap:
info->writes_memory = true;
break;
+   case nir_intrinsic_load_var: {
+   nir_variable *var = intr->variables[0]->var;
+   nir_variable_mode mode = var->data.mode;
+   enum glsl_base_type base_type =
+   
glsl_get_base_type(glsl_without_array(var->type));
+
+   if (mode == nir_var_shader_in) {
+   switch (var->data.interpolation) {
+   case INTERP_MODE_NONE:
+   if 
(glsl_base_type_is_integer(base_type))
+   break;
+
+   /* fall-through */
+   case INTERP_MODE_SMOOTH:
+   if (var->data.sample)
+   info->uses_persp_sample = true;
+   else if (var->data.centroid)
+   info->uses_persp_centroid = 
true;
+   else
+   info->uses_persp_center = true;
+   break;
+
+   case INTERP_MODE_NOPERSPECTIVE:
+   if (var->data.sample)
+   info->uses_linear_sample = true;
+   else if (var->data.centroid)
+   info->uses_linear_centroid = 
true;
+   else
+   info->uses_linear_center = true;
+   break;
+   }
+   }
+   break;
+   }
case nir_intrinsic_interp_var_at_centroid:
case nir_intrinsic_interp_var_at_sample:
case nir_intrinsic_interp_var_at_offset: {
@@ -296,34 +330,20 @@ void si_nir_scan_shader(const struct nir_shader *nir,
 
if (semantic_name == TGSI_SEMANTIC_COLOR) {
info->input_interpolate[i] = 
TGSI_INTERPOLATE_COLOR;
-   goto persp_locations;
+   break;
}
/* fall-through */
+
case INTERP_MODE_SMOOTH:
assert(!glsl_base_type_is_integer(base_type));
 
info->input_interpolate[i] = 
TGSI_INTERPOLATE_PERSPECTIVE;
-
-   persp_locations:
-   if (variable->data.sample)
-   info->uses_persp_sample = true;
-   else if (variable->data.centroid)
-   info->uses_persp_centroid = true;
-   else
-   info->uses_persp_center = true;
break;
 
case INTERP_MODE_NOPERSPECTIVE:
assert(!glsl_base_type_is_integer(base_type));
 
info->input_interpolate[i] = TGSI_INTERPOLATE_LINEAR;
-
-   if (variable->data.sample)
-   info->uses_linear_sample = true;
-   else if (variable->data.centroid)
-   info->uses_linear_centroid = true;
-   else
-   info->uses_linear_center = true;
break;
 
case INTERP_MODE_FLAT:
-- 
2.14.3

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


[Mesa-dev] [PATCH v2 03/12] ac/nir_to_llvm: move some interp defines to the header

2018-01-29 Thread Timothy Arceri
These will be used in the following patch.
---
 src/amd/common/ac_nir_to_llvm.c | 4 
 src/amd/common/ac_nir_to_llvm.h | 5 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index b3336ffafe..bcacd4953f 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -3976,10 +3976,6 @@ static LLVMValueRef visit_var_atomic(struct 
nir_to_llvm_context *ctx,
return result;
 }
 
-#define INTERP_CENTER 0
-#define INTERP_CENTROID 1
-#define INTERP_SAMPLE 2
-
 static LLVMValueRef lookup_interp_param(struct nir_to_llvm_context *ctx,
enum glsl_interp_mode interp, unsigned 
location)
 {
diff --git a/src/amd/common/ac_nir_to_llvm.h b/src/amd/common/ac_nir_to_llvm.h
index 1484bf1d83..023200ace8 100644
--- a/src/amd/common/ac_nir_to_llvm.h
+++ b/src/amd/common/ac_nir_to_llvm.h
@@ -118,6 +118,11 @@ enum ac_ud_index {
AC_UD_MAX_UD = AC_UD_TCS_MAX_UD,
 };
 
+/* Interpolation locations */
+#define INTERP_CENTER 0
+#define INTERP_CENTROID 1
+#define INTERP_SAMPLE 2
+
 /* descriptor index into scratch ring offsets */
 #define RING_SCRATCH 0
 #define RING_ESGS_VS 1
-- 
2.14.3

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


[Mesa-dev] [PATCH v2 01/12] radeonsi/nir: add interpolate at intrinsics to scan_instruction()

2018-01-29 Thread Timothy Arceri
V2: use the uses_*_opcode_interp_* flags
---
 src/gallium/drivers/radeonsi/si_shader_nir.c | 30 
 1 file changed, 30 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c 
b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 453d31bd13..6368b71206 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -127,6 +127,36 @@ static void scan_instruction(struct tgsi_shader_info *info,
case nir_intrinsic_ssbo_atomic_comp_swap:
info->writes_memory = true;
break;
+   case nir_intrinsic_interp_var_at_centroid:
+   case nir_intrinsic_interp_var_at_sample:
+   case nir_intrinsic_interp_var_at_offset: {
+   enum glsl_interp_mode interp =
+   intr->variables[0]->var->data.interpolation;
+   switch (interp) {
+   case INTERP_MODE_SMOOTH:
+   case INTERP_MODE_NONE:
+   if (intr->intrinsic == 
nir_intrinsic_interp_var_at_centroid)
+   info->uses_persp_opcode_interp_centroid 
= true;
+   else if (intr->intrinsic == 
nir_intrinsic_interp_var_at_sample)
+   info->uses_persp_opcode_interp_sample = 
true;
+   else
+   info->uses_persp_opcode_interp_offset = 
true;
+   break;
+   case INTERP_MODE_NOPERSPECTIVE:
+   if (intr->intrinsic == 
nir_intrinsic_interp_var_at_centroid)
+   
info->uses_linear_opcode_interp_centroid = true;
+   else if (intr->intrinsic == 
nir_intrinsic_interp_var_at_sample)
+   info->uses_linear_opcode_interp_sample 
= true;
+   else
+   info->uses_linear_opcode_interp_offset 
= true;
+   break;
+   case INTERP_MODE_FLAT:
+   break;
+   default:
+   unreachable("Unsupported interpoation type");
+   }
+   break;
+   }
default:
break;
}
-- 
2.14.3

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


Re: [Mesa-dev] [PATCH v1 0/7] Implement commont gralloc_handle_t in libdrm

2018-01-29 Thread Tomasz Figa
Hi Rob,

On Tue, Jan 30, 2018 at 1:17 AM, Robert Foss  wrote:
> Hey Tomasz,
>
> I'm tempted to split this work into two parts.
> 1) Move gbm&drm gralloc struct

Alright, if we look at this only as an attempt to converge gbm_ and
drm_gralloc, it's out of my scope and no concern anymore.

> 2) Accessor functions
>
> I would like to get 1) out the door to support John Stultzs current HiKey
> 960 efforts. As for 2), it would seem that we have some more discussing to
> do. But I'll keep pushing that forward.
>
> Separately, I'd like to know if the below sketch of a func ptr solution is
> what you had in mind. From what I've gathered this is exactly what you've
> requested, but I would like to confirm it too.

I assume you mean the ones below?

>
> I'll send out a v2, that covers 1) later today.
>
>
> Rob.
>
>
> On 01/29/2018 01:03 PM, Robert Foss wrote:
[snip]
>>
>>>
  uint32_t (*get_fd)(buffer_handle_t handle, uint32_t plane);
  uint64_t (*get_modifier)(buffer_handle_t handle, uint32_t plane);
  uint32_t (*get_offsets)(buffer_handle_t handle, uint32_t plane);
  uint32_t (*get_stride)(buffer_handle_t handle, uint32_t plane);
  ...
 } gralloc_funcs_t;

These ones?

Yeah, if we could retrieve such function pointer struct using perform
or any equivalent (like the implementation-specific methods in
gralloc1, but not sure if that's going to be used in practice
anywhere), it could work for us.

I think we could also add .get_fourcc(handle) and
.get_num_planes(handle) callbacks, so that we could do away with the
whole sophisticated format guessing based on Android HAL format and
lock_ycbcr results.

Perhaps an integer version field would also be useful, in case we end
up adding some more callbacks.

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


[Mesa-dev] [PATCH] r600/eg: add crap indirect compute support.

2018-01-29 Thread Dave Airlie
From: Dave Airlie 

I think the cp packets can be made work, but I think it might
need a kernel change, so for now just do the worst thing.
---
 src/gallium/drivers/r600/evergreen_compute.c | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_compute.c 
b/src/gallium/drivers/r600/evergreen_compute.c
index 7880d0f..b2c724f 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -630,13 +630,25 @@ static void evergreen_emit_dispatch(struct r600_context 
*rctx,
radeon_compute_set_context_reg(cs, R_0288E8_SQ_LDS_ALLOC,
lds_size | (num_waves << 14));
 
-   /* Dispatch packet */
-   radeon_emit(cs, PKT3C(PKT3_DISPATCH_DIRECT, 3, 0));
-   radeon_emit(cs, info->grid[0]);
-   radeon_emit(cs, info->grid[1]);
-   radeon_emit(cs, info->grid[2]);
-   /* VGT_DISPATCH_INITIATOR = COMPUTE_SHADER_EN */
-   radeon_emit(cs, 1);
+   if (info->indirect) {
+   struct r600_resource *indirect_resource = (struct r600_resource 
*)info->indirect;
+   unsigned *data = r600_buffer_map_sync_with_rings(&rctx->b, 
indirect_resource, PIPE_TRANSFER_READ);
+   if (data) {
+   radeon_emit(cs, PKT3C(PKT3_DISPATCH_DIRECT, 3, 0));
+   radeon_emit(cs, data[0]);
+   radeon_emit(cs, data[1]);
+   radeon_emit(cs, data[2]);
+   radeon_emit(cs, 1);
+   }
+   } else {
+   /* Dispatch packet */
+   radeon_emit(cs, PKT3C(PKT3_DISPATCH_DIRECT, 3, 0));
+   radeon_emit(cs, info->grid[0]);
+   radeon_emit(cs, info->grid[1]);
+   radeon_emit(cs, info->grid[2]);
+   /* VGT_DISPATCH_INITIATOR = COMPUTE_SHADER_EN */
+   radeon_emit(cs, 1);
+   }
 
if (rctx->is_debug)
eg_trace_emit(rctx);
-- 
2.1.0

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


Re: [Mesa-dev] [PATCH 3/3] mesa: skip validation of legality of size/type queries for format queries

2018-01-29 Thread Roland Scheidegger
Am 29.01.2018 um 17:03 schrieb Alejandro Piñeiro:
> On 29/01/18 16:38, Roland Scheidegger wrote:
>> Am 29.01.2018 um 09:09 schrieb Alejandro Piñeiro:
>>>
>>> On 27/01/18 12:09, Roland Scheidegger wrote:
 Am 27.01.2018 um 09:52 schrieb Alejandro Piñeiro:
> On 27/01/18 01:59, srol...@vmware.com wrote:
>> From: Roland Scheidegger 
>>
>> The size/type query is always legal (if we made it that far).
>> This causes a difference for GL_TEXTURE_BUFFER - the reason is that these
>> parameters are valid only with GetTexLevelParameter() if gl 3.1 is 
>> supported,
>> but not if only ARB_texture_buffer_object is supported.
>> However, while the spec says that these queries return "the same 
>> information
>> as querying GetTexLevelParameter" I believe we're not expected to return 
>> just
>> zeros here. By definition, these pnames are always valid (unlike for the
>> GetTexLevelParameter() function which would return an error without GL 
>> 3.1),
>> so returning 0 but no error makes no sense to me.
> But in general, AFAIU, this is how GetInternalFormat works. The
> extension only raises an error if their API is not used properly.  But
> not if the combination being requested doesn't make sense.
>
> For example, the pname GET_TEXTURE_IMAGE_FORMAT, would return the same
> value that using GetTexImage. But if the resource is not supported by
> GetTextImage, it should return NONE, but not raising an error. So for
> example, you could use as target GL_RENDERBUFFER for
> GET_TEXTURE_IMAGE_FORMAT query, and  just get a GL_NONE, but no an
> error. While that one would raise an error on GetTexImage.
 This is correct, but I don't think that's really comparable. The case
 you cited is if something isn't supported - this is not the case here at
 all, if some format with TEXTURE_BUFFER is supported, we're just lying
 about the size/type because ARB_tbo made these properties non-queryable.
>>> Are not queryable for specific GL versions, as you said. For me it would
>>> be inconsistent if you are able to query the tbo sizes with
>>> GetInternalformat, but not with gettexlevelparameter on a given opengl
>>> version. Raising or not an error should not be a reason to discard it,
>>> because as I said, ARB_internalformat_query2 in general avoid raising GL
>>> error for unsupported cases.
>>>
>>> What I'm trying to say is that the current implementation is not wrong,
>>> just more literal to the current spec wording. Yes, perhaps too literal
>>> in some cases. But I also have the feeling that your patch pushes too
>>> much on the supposed original intention of this query.
>>>
>>> Having said so, this is just my opinion. So if anyone else agrees with
>>> your interpretation of the desired behaviour on this query, I don't
>>> think that it is a big deal to include this patch.
>> There's actually a specific bit in the internalformat_query2 which makes
>> me think is a pretty good hint that "return the same information as
>> querying GetTeXLevelParameter" should not be taken literally and is just
>> informational: The part about GL_INTERNALFORMAT_STENCIL_TYPE - since the
>> language applies to that as well, however an equivalent pname for
>> GetTeXLevelParameter does not even exist.
> 
> Hmm, good point. And as the code is right now, it filters the target
> based on being supported or not by GetTexLevelParameter, but then (if
> the target is not filtered), returns a value for STENCIL_TYPE, even
> although GetTexLevelParameter doesn't have a equivalent pname/query.
> 
>> And imho even if you take it literally, it's ambiguos at best, since the
>> same paragraph doesn't just mention the "return the same as..." part,
>> but also explicitly says that 0/none is returned if the format is
>> unsupported, which contradicts this part (well you can of course
>> interpret it that this is not a sufficient condition to return 0, but I
>> don't think that was the intention).
> 
> In general, this spec has a lot (too much?) of room for interpretation.
Yes, I agree with that. (Of course it doesn't help that the dependency
section is absolutely massive.)

> 
>> I agree though my interpretation is more in line what I think was
>> probably the intention and can't directly be derived from the wording -
>> in general however you can always use all pname/target bits and get
>> valid answers iff the format/pname combination is supported, so this not
>> working texture_buffer would be very awkward imho.
>>
>> But maybe someone more familiar with the spec could chime in...
> 
> I will open a spec issue for this. Meanwhile they reply:
> 
> Reviewed-by: Alejandro Piñeiro 
> 
> (Although I would appreciate some additional info on the commit message)
Ok, thanks for reviewing, I added some more info on the commit message.

Roland

> 
> As you mentioned, both interpretations have a little of inconsistency.
> If khronos, or someone chiming in, clarifies

Re: [Mesa-dev] [PATCH] ac: Use old kill intrinsics for LLVM 6.

2018-01-29 Thread Samuel Pitoiset



On 01/30/2018 12:03 AM, Bas Nieuwenhuizen wrote:

llvm.amdgcn.kill is currently broken for SGPRs. The old intrinsic
had that issue too, but did not fold the preceding comparison into
the machine instruction in LLVM. As the preceding comparison is
often a float comparison, this results in a VGPR, essentially hiding
the issue.

I have a fix outstanding for LLVM to make the new intrinsic work,
but as getting stuff reviewed, committed and cherry-picked in LLVM
takes quite a while, I'd like to be safe and disable the new
intrinsic with LLVM 6.

We can always revert when the fix is in LLVM.


Yes, I do agree.

Reviewed-by: Samuel Pitoiset 



Fixes: ad2b3b2a9c "ac: replace llvm.AMDGPU.kilp by llvm.amdgcn.kill with LLVM 6"
---

The LLVM fix is available at https://reviews.llvm.org/D42302

  src/amd/common/ac_llvm_build.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 5e08508fed..a34eda1037 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -1479,7 +1479,7 @@ LLVMValueRef ac_build_wqm_vote(struct ac_llvm_context 
*ctx, LLVMValueRef i1)
  
  void ac_build_kill_if_false(struct ac_llvm_context *ctx, LLVMValueRef i1)

  {
-   if (HAVE_LLVM >= 0x0600) {
+   if (HAVE_LLVM >= 0x0700) {
ac_build_intrinsic(ctx, "llvm.amdgcn.kill", ctx->voidt,
   &i1, 1, 0);
return;


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


Re: [Mesa-dev] [PATCH shaderdb 1/3] run: split out helper to create contexts

2018-01-29 Thread Matt Turner
All three look good to me. Thanks for doing this. It's been on my todo
list for a while.

The ES shaders we have in our internal shader-db have been working
because of ARB_ES*_compatibility, which I guess could be used to avoid
some API switches, but that only worked out more or less by accident
in the current code.

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


Re: [Mesa-dev] [PATCH] meson: Add new picture_{h264, hevc}_enc.c files to meson too

2018-01-29 Thread Zhang, Boyuan
Thanks a lot for pointing out, I add meson changes too.


Regards,

Boyuan


From: Boyuan Zhang 

Subject: [PATCH 06/12] st/va: move H264 enc functions into separate file

Signed-off-by: Boyuan Zhang 
---
 src/gallium/state_trackers/va/Makefile.sources   |   1 +
 src/gallium/state_trackers/va/meson.build|   2 +-
 src/gallium/state_trackers/va/picture.c  | 146 +++-
 src/gallium/state_trackers/va/picture_h264_enc.c | 163 +++
 src/gallium/state_trackers/va/va_private.h   |   5 +
 5 files changed, 219 insertions(+), 98 deletions(-)
 create mode 100644 src/gallium/state_trackers/va/picture_h264_enc.c

diff --git a/src/gallium/state_trackers/va/Makefile.sources 
b/src/gallium/state_trackers/va/Makefile.sources
index 2d6546b..8a69828 100644
--- a/src/gallium/state_trackers/va/Makefile.sources
+++ b/src/gallium/state_trackers/va/Makefile.sources
@@ -8,6 +8,7 @@ C_SOURCES := \
 picture_mpeg12.c \
 picture_mpeg4.c \
 picture_h264.c \
+picture_h264_enc.c \
 picture_hevc.c \
 picture_vc1.c \
 picture_mjpeg.c \
diff --git a/src/gallium/state_trackers/va/meson.build 
b/src/gallium/state_trackers/va/meson.build
index 56e68e9..bddd5ef 100644
--- a/src/gallium/state_trackers/va/meson.build
+++ b/src/gallium/state_trackers/va/meson.build
@@ -26,7 +26,7 @@ libva_st = static_library(
 'buffer.c', 'config.c', 'context.c', 'display.c', 'image.c', 'picture.c',
 'picture_mpeg12.c', 'picture_mpeg4.c', 'picture_h264.c', 'picture_hevc.c',
 'picture_vc1.c', 'picture_mjpeg.c', 'postproc.c', 'subpicture.c',
-'surface.c',
+'surface.c', 'picture_h264_enc.c', 'picture_hevc_enc.c',
   ),
   c_args : [
 c_vis_args,
diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c
index 8951573..77d379b 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -349,55 +349,52 @@ handleVASliceDataBufferType(vlVaContext *context, 
vlVaBuffer *buf)
 static VAStatus
 handleVAEncMiscParameterTypeRateControl(vlVaContext *context, 
VAEncMiscParameterBuffer *misc)
 {
-   VAEncMiscParameterRateControl *rc = (VAEncMiscParameterRateControl 
*)misc->data;
-   if (context->desc.h264enc.rate_ctrl.rate_ctrl_method ==
-   PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT)
-  context->desc.h264enc.rate_ctrl.target_bitrate = rc->bits_per_second;
-   else
-  context->desc.h264enc.rate_ctrl.target_bitrate = rc->bits_per_second * 
(rc->target_percentage / 100.0);
-   context->desc.h264enc.rate_ctrl.peak_bitrate = rc->bits_per_second;
-   if (context->desc.h264enc.rate_ctrl.target_bitrate < 200)
-  context->desc.h264enc.rate_ctrl.vbv_buffer_size = 
MIN2((context->desc.h264enc.rate_ctrl.target_bitrate * 2.75), 200);
-   else
-  context->desc.h264enc.rate_ctrl.vbv_buffer_size = 
context->desc.h264enc.rate_ctrl.target_bitrate;
+   VAStatus status = VA_STATUS_SUCCESS;

-   return VA_STATUS_SUCCESS;
+   switch (u_reduce_video_profile(context->templat.profile)) {
+   case PIPE_VIDEO_FORMAT_MPEG4_AVC:
+  status = vlVaHandleVAEncMiscParameterTypeRateControlH264(context, misc);
+  break;
+
+   default:
+  break;
+   }
+
+   return status;
 }

 static VAStatus
 handleVAEncMiscParameterTypeFrameRate(vlVaContext *context, 
VAEncMiscParameterBuffer *misc)
 {
-   VAEncMiscParameterFrameRate *fr = (VAEncMiscParameterFrameRate *)misc->data;
-   if (fr->framerate & 0x) {
-  context->desc.h264enc.rate_ctrl.frame_rate_num = fr->framerate   & 
0x;
-  context->desc.h264enc.rate_ctrl.frame_rate_den = fr->framerate >> 16 & 
0x;
-   } else {
-  context->desc.h264enc.rate_ctrl.frame_rate_num = fr->framerate;
-  context->desc.h264enc.rate_ctrl.frame_rate_den = 1;
+   VAStatus status = VA_STATUS_SUCCESS;
+
+   switch (u_reduce_video_profile(context->templat.profile)) {
+   case PIPE_VIDEO_FORMAT_MPEG4_AVC:
+  status = vlVaHandleVAEncMiscParameterTypeFrameRateH264(context, misc);
+  break;
+
+   default:
+  break;
}
-   return VA_STATUS_SUCCESS;
+
+   return status;
 }

 static VAStatus
 handleVAEncSequenceParameterBufferType(vlVaDriver *drv, vlVaContext *context, 
vlVaBuffer *buf)
 {
-   VAEncSequenceParameterBufferH264 *h264 = (VAEncSequenceParameterBufferH264 
*)buf->data;
-   if (!context->decoder) {
-  context->templat.max_references = h264->max_num_ref_frames;
-  context->templat.level = h264->level_idc;
-  context->decoder = drv->pipe->create_video_codec(drv->pipe, 
&context->templat);
-  if (!context->decoder)
- return VA_STATUS_ERROR_ALLOCATION_FAILED;
+   VAStatus status = VA_STATUS_SUCCESS;
+
+   switch (u_reduce_video_profile(context->templat.profile)) {
+   case PIPE_VIDEO_FORMAT_MPEG4_AVC:
+  status = vlVaHandleVAEncSequenceParameterBufferTypeH264(drv, context, 
buf);
+  break;
+
+   default:
+  break;
}

-   context->gop_coeff = ((1024 + h264->intra_idr_period - 1) / 
h264->

[Mesa-dev] [PATCH] ac: Use old kill intrinsics for LLVM 6.

2018-01-29 Thread Bas Nieuwenhuizen
llvm.amdgcn.kill is currently broken for SGPRs. The old intrinsic
had that issue too, but did not fold the preceding comparison into
the machine instruction in LLVM. As the preceding comparison is
often a float comparison, this results in a VGPR, essentially hiding
the issue.

I have a fix outstanding for LLVM to make the new intrinsic work,
but as getting stuff reviewed, committed and cherry-picked in LLVM
takes quite a while, I'd like to be safe and disable the new
intrinsic with LLVM 6.

We can always revert when the fix is in LLVM.

Fixes: ad2b3b2a9c "ac: replace llvm.AMDGPU.kilp by llvm.amdgcn.kill with LLVM 6"
---

The LLVM fix is available at https://reviews.llvm.org/D42302

 src/amd/common/ac_llvm_build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 5e08508fed..a34eda1037 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -1479,7 +1479,7 @@ LLVMValueRef ac_build_wqm_vote(struct ac_llvm_context 
*ctx, LLVMValueRef i1)
 
 void ac_build_kill_if_false(struct ac_llvm_context *ctx, LLVMValueRef i1)
 {
-   if (HAVE_LLVM >= 0x0600) {
+   if (HAVE_LLVM >= 0x0700) {
ac_build_intrinsic(ctx, "llvm.amdgcn.kill", ctx->voidt,
   &i1, 1, 0);
return;
-- 
2.16.1

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


Re: [Mesa-dev] [PATCH 8/8] st/glsl_to_nir: disable io lowering and forced indirect array splitting in fs

2018-01-29 Thread Timothy Arceri

On 30/01/18 09:30, Connor Abbott wrote:

When I was talking about handling I/O for radeonsi NIR with Nicolai, I
think the conclusion was that the best way forward is to make the
driver call nir_lower_io and friends, at least for inputs and outputs.
This is a perfect example of the kind of hacks that we have to do --
precisely how to handle inputs is a driver-specific thing, and piling
up special cases like this in the state tracker is just unsustainable.

As an aside, we probably should be using the load_barycentric_*
intrinsics, which would make the code for interpolateAt* much cleaner
for radeonsi, since we don't have to deal with variable derefs. The
goal should be to eliminatem manual deref walking and offset
calculation from radeonsi nir entirely, it shouldn't be necessary at
all.


That is probably a nice goal longer term but currently the shared nir to 
llvm code expects nir_lower_io not to be used. For now I'm planning on 
adding a CAP here rather than using glsl version, as suggested by others.


I'd first like to get nir for radeonsi passing piglit before tackling 
any large refactors to the shared nir to llvm code, besides the forced 
lowering and array splitting is the real hack here and this patch is 
avoiding that.




Connor


On Sun, Jan 14, 2018 at 10:46 PM, Timothy Arceri  wrote:

We need this to be able to support the interpolateAt builtins in a
sane way. It also leads to the generation of more optimal code.

The lowering and splitting is made conditional on glsl 400 because
vc4 and freedreno both expect these passes to be enabled and niether
support glsl 400 so don't need to deal with the interpolateAt builtins.

We leave the other stages for now as to avoid regressions.
---
  src/mesa/state_tracker/st_glsl_to_nir.cpp | 13 +++--
  1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 6e3a1548f4..bc55c5b7db 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -461,7 +461,9 @@ st_nir_get_mesa_program(struct gl_context *ctx,
  struct gl_linked_shader *shader)
  {
 struct st_context *st = st_context(ctx);
+   struct pipe_screen *screen = st->pipe->screen;
 struct gl_program *prog;
+   unsigned glsl_version = screen->get_param(screen, 
PIPE_CAP_GLSL_FEATURE_LEVEL);

 validate_ir_tree(shader->ir);

@@ -491,11 +493,14 @@ st_nir_get_mesa_program(struct gl_context *ctx,
 prog->nir = nir;

 if (nir->info.stage != MESA_SHADER_TESS_CTRL &&
-   nir->info.stage != MESA_SHADER_TESS_EVAL) {
+   nir->info.stage != MESA_SHADER_TESS_EVAL &&
+   (nir->info.stage != MESA_SHADER_FRAGMENT ||
+(glsl_version < 400 && nir->info.stage == MESA_SHADER_FRAGMENT))) {
NIR_PASS_V(nir, nir_lower_io_to_temporaries,
   nir_shader_get_entrypoint(nir),
   true, true);
 }
+
 NIR_PASS_V(nir, nir_lower_global_vars_to_local);
 NIR_PASS_V(nir, nir_split_var_copies);
 NIR_PASS_V(nir, nir_lower_var_copies);
@@ -665,12 +670,16 @@ st_finalize_nir(struct st_context *st, struct gl_program 
*prog,
  struct gl_shader_program *shader_program, nir_shader *nir)
  {
 struct pipe_screen *screen = st->pipe->screen;
+   unsigned glsl_version = screen->get_param(screen, 
PIPE_CAP_GLSL_FEATURE_LEVEL);

 NIR_PASS_V(nir, nir_split_var_copies);
 NIR_PASS_V(nir, nir_lower_var_copies);
 if (nir->info.stage != MESA_SHADER_TESS_CTRL &&
-   nir->info.stage != MESA_SHADER_TESS_EVAL)
+   nir->info.stage != MESA_SHADER_TESS_EVAL &&
+   (nir->info.stage != MESA_SHADER_FRAGMENT ||
+(glsl_version < 400 && nir->info.stage == MESA_SHADER_FRAGMENT))) {
NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects);
+   }

 if (nir->info.stage == MESA_SHADER_VERTEX) {
/* Needs special handling so drvloc matches the vbo state: */
--
2.14.3

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

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


Re: [Mesa-dev] [PATCH] anv/pipeline: lower constant initializers on output variables earlier

2018-01-29 Thread Jason Ekstrand
Reviewed-by: Jason Ekstrand 

On Wed, Jan 17, 2018 at 12:08 AM, Iago Toral Quiroga 
wrote:

> If a shader only writes to an output via a constant initializer we
> need to lower it before we call nir_remove_dead_variables so that
> this pass sees the stores from the initializer and doesn't kill the
> output.
>
> Fixes test failures in new work-in-progress CTS tests:
> dEQP-VK.spirv_assembly.instruction.graphics.variable_init.output_vert
> dEQP-VK.spirv_assembly.instruction.graphics.variable_init.output_frag
> ---
>  src/intel/vulkan/anv_pipeline.c | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_
> pipeline.c
> index 4e66f8665f..fe0a3fc30a 100644
> --- a/src/intel/vulkan/anv_pipeline.c
> +++ b/src/intel/vulkan/anv_pipeline.c
> @@ -179,6 +179,11 @@ anv_shader_compile_to_nir(struct anv_pipeline
> *pipeline,
> assert(exec_list_length(&nir->functions) == 1);
> entry_point->name = ralloc_strdup(entry_point, "main");
>
> +   /* Make sure we lower constant initializers on output variables so that
> +* nir_remove_dead_variables below sees the corresponding stores
> +*/
> +   NIR_PASS_V(nir, nir_lower_constant_initializers, nir_var_shader_out);
> +
> NIR_PASS_V(nir, nir_remove_dead_variables,
>nir_var_shader_in | nir_var_shader_out |
> nir_var_system_value);
>
> --
> 2.14.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 14/24] intel/blorp: Add a CCS ambiguation pass

2018-01-29 Thread Jason Ekstrand
On Mon, Jan 29, 2018 at 7:21 AM, Pohjolainen, Topi <
topi.pohjolai...@gmail.com> wrote:

> On Fri, Jan 26, 2018 at 05:58:25PM +0200, Pohjolainen, Topi wrote:
> > On Wed, Jan 24, 2018 at 12:29:05PM -0800, Jason Ekstrand wrote:
> > > On Wed, Jan 24, 2018 at 6:15 AM, Pohjolainen, Topi <
> > > topi.pohjolai...@gmail.com> wrote:
> > >
> > > > On Fri, Jan 19, 2018 at 03:47:31PM -0800, Jason Ekstrand wrote:
> > > > > This pass performs an "ambiguate" operation on a CCS-compressed
> surface
> > > > > by manually writing zeros into the CCS.  On gen8+, ISL gives us a
> fairly
> > > > > detailed notion of how the CCS is laid out so this is fairly
> simple to
> > > > > do.  On gen7, the CCS tiling is quite crazy but that isn't an issue
> > > > > because we can only do CCS on single-slice images so we can just
> blast
> > > > > over the entire CCS buffer if we want to.
> > > > > ---
> > > > >  src/intel/blorp/blorp.h   |   5 ++
> > > > >  src/intel/blorp/blorp_clear.c | 149 ++
> > > > 
> > > > >  2 files changed, 154 insertions(+)
> > > > >
> > > > > diff --git a/src/intel/blorp/blorp.h b/src/intel/blorp/blorp.h
> > > > > index a1dd571..478a9af 100644
> > > > > --- a/src/intel/blorp/blorp.h
> > > > > +++ b/src/intel/blorp/blorp.h
> > > > > @@ -204,6 +204,11 @@ blorp_ccs_resolve(struct blorp_batch *batch,
> > > > >enum blorp_fast_clear_op resolve_op);
> > > > >
> > > > >  void
> > > > > +blorp_ccs_ambiguate(struct blorp_batch *batch,
> > > > > +struct blorp_surf *surf,
> > > > > +uint32_t level, uint32_t layer);
> > > > > +
> > > > > +void
> > > > >  blorp_mcs_partial_resolve(struct blorp_batch *batch,
> > > > >struct blorp_surf *surf,
> > > > >enum isl_format format,
> > > > > diff --git a/src/intel/blorp/blorp_clear.c
> > > > b/src/intel/blorp/blorp_clear.c
> > > > > index 8e7bc9f..fa2abd9 100644
> > > > > --- a/src/intel/blorp/blorp_clear.c
> > > > > +++ b/src/intel/blorp/blorp_clear.c
> > > > > @@ -881,3 +881,152 @@ blorp_mcs_partial_resolve(struct blorp_batch
> > > > *batch,
> > > > >
> > > > > batch->blorp->exec(batch, ¶ms);
> > > > >  }
> > > > > +
> > > > > +/** Clear a CCS to the "uncompressed" state
> > > > > + *
> > > > > + * This pass is the CCS equivalent of a "HiZ resolve".  It sets
> the CCS
> > > > values
> > > > > + * for a given layer/level of a surface to 0x0 which is the
> > > > "uncompressed"
> > > > > + * state which tells the sampler to go look at the main surface.
> > > > > + */
> > > > > +void
> > > > > +blorp_ccs_ambiguate(struct blorp_batch *batch,
> > > > > +struct blorp_surf *surf,
> > > > > +uint32_t level, uint32_t layer)
> > > > > +{
> > > > > +   struct blorp_params params;
> > > > > +   blorp_params_init(¶ms);
> > > > > +
> > > > > +   assert(ISL_DEV_GEN(batch->blorp->isl_dev) >= 7);
> > > > > +
> > > > > +   const struct isl_format_layout *aux_fmtl =
> > > > > +  isl_format_get_layout(surf->aux_surf->format);
> > > > > +   assert(aux_fmtl->txc == ISL_TXC_CCS);
> > > > > +
> > > > > +   params.dst = (struct brw_blorp_surface_info) {
> > > > > +  .enabled = true,
> > > > > +  .addr = surf->aux_addr,
> > > > > +  .view = {
> > > > > + .usage = ISL_SURF_USAGE_RENDER_TARGET_BIT,
> > > > > + .format = ISL_FORMAT_R32G32B32A32_UINT,
> > > > > + .base_level = 0,
> > > > > + .base_array_layer = 0,
> > > > > + .levels = 1,
> > > > > + .array_len = 1,
> > > > > + .swizzle = ISL_SWIZZLE_IDENTITY,
> > > > > +  },
> > > > > +   };
> > > > > +
> > > > > +   uint32_t z = 0;
> > > > > +   if (surf->surf->dim == ISL_SURF_DIM_3D) {
> > > > > +  z = layer;
> > > > > +  layer = 0;
> > > > > +   }
> > > > > +
> > > > > +   uint32_t offset_B, x_offset_el, y_offset_el;
> > > > > +   isl_surf_get_image_offset_el(surf->aux_surf, level, layer, z,
> > > > > +&x_offset_el, &y_offset_el);
> > > > > +   isl_tiling_get_intratile_offset_el(surf->aux_surf->tiling,
> > > > aux_fmtl->bpb,
> > > > > +  surf->aux_surf->row_pitch,
> > > > > +  x_offset_el, y_offset_el,
> > > > > +  &offset_B, &x_offset_el,
> > > > &y_offset_el);
> > > > > +   params.dst.addr.offset += offset_B;
> > > > > +
> > > > > +   const uint32_t width_px = minify(surf->surf->logical_
> level0_px.width,
> > > > level);
> > > > > +   const uint32_t height_px = minify(surf->surf->logical_
> level0_px.height,
> > > > level);
> > > > > +   const uint32_t width_el = DIV_ROUND_UP(width_px, aux_fmtl->bw);
> > > > > +   const uint32_t height_el = DIV_ROUND_UP(height_px,
> aux_fmtl->bh);
> >
> > I need to think about these numbers a little more. I think I got the
> other
> > sources of my confusion figured out further down. See further down.

Re: [Mesa-dev] [PATCH 8/8] st/glsl_to_nir: disable io lowering and forced indirect array splitting in fs

2018-01-29 Thread Connor Abbott
When I was talking about handling I/O for radeonsi NIR with Nicolai, I
think the conclusion was that the best way forward is to make the
driver call nir_lower_io and friends, at least for inputs and outputs.
This is a perfect example of the kind of hacks that we have to do --
precisely how to handle inputs is a driver-specific thing, and piling
up special cases like this in the state tracker is just unsustainable.

As an aside, we probably should be using the load_barycentric_*
intrinsics, which would make the code for interpolateAt* much cleaner
for radeonsi, since we don't have to deal with variable derefs. The
goal should be to eliminatem manual deref walking and offset
calculation from radeonsi nir entirely, it shouldn't be necessary at
all.

Connor


On Sun, Jan 14, 2018 at 10:46 PM, Timothy Arceri  wrote:
> We need this to be able to support the interpolateAt builtins in a
> sane way. It also leads to the generation of more optimal code.
>
> The lowering and splitting is made conditional on glsl 400 because
> vc4 and freedreno both expect these passes to be enabled and niether
> support glsl 400 so don't need to deal with the interpolateAt builtins.
>
> We leave the other stages for now as to avoid regressions.
> ---
>  src/mesa/state_tracker/st_glsl_to_nir.cpp | 13 +++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
> b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> index 6e3a1548f4..bc55c5b7db 100644
> --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> @@ -461,7 +461,9 @@ st_nir_get_mesa_program(struct gl_context *ctx,
>  struct gl_linked_shader *shader)
>  {
> struct st_context *st = st_context(ctx);
> +   struct pipe_screen *screen = st->pipe->screen;
> struct gl_program *prog;
> +   unsigned glsl_version = screen->get_param(screen, 
> PIPE_CAP_GLSL_FEATURE_LEVEL);
>
> validate_ir_tree(shader->ir);
>
> @@ -491,11 +493,14 @@ st_nir_get_mesa_program(struct gl_context *ctx,
> prog->nir = nir;
>
> if (nir->info.stage != MESA_SHADER_TESS_CTRL &&
> -   nir->info.stage != MESA_SHADER_TESS_EVAL) {
> +   nir->info.stage != MESA_SHADER_TESS_EVAL &&
> +   (nir->info.stage != MESA_SHADER_FRAGMENT ||
> +(glsl_version < 400 && nir->info.stage == MESA_SHADER_FRAGMENT))) {
>NIR_PASS_V(nir, nir_lower_io_to_temporaries,
>   nir_shader_get_entrypoint(nir),
>   true, true);
> }
> +
> NIR_PASS_V(nir, nir_lower_global_vars_to_local);
> NIR_PASS_V(nir, nir_split_var_copies);
> NIR_PASS_V(nir, nir_lower_var_copies);
> @@ -665,12 +670,16 @@ st_finalize_nir(struct st_context *st, struct 
> gl_program *prog,
>  struct gl_shader_program *shader_program, nir_shader *nir)
>  {
> struct pipe_screen *screen = st->pipe->screen;
> +   unsigned glsl_version = screen->get_param(screen, 
> PIPE_CAP_GLSL_FEATURE_LEVEL);
>
> NIR_PASS_V(nir, nir_split_var_copies);
> NIR_PASS_V(nir, nir_lower_var_copies);
> if (nir->info.stage != MESA_SHADER_TESS_CTRL &&
> -   nir->info.stage != MESA_SHADER_TESS_EVAL)
> +   nir->info.stage != MESA_SHADER_TESS_EVAL &&
> +   (nir->info.stage != MESA_SHADER_FRAGMENT ||
> +(glsl_version < 400 && nir->info.stage == MESA_SHADER_FRAGMENT))) {
>NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects);
> +   }
>
> if (nir->info.stage == MESA_SHADER_VERTEX) {
>/* Needs special handling so drvloc matches the vbo state: */
> --
> 2.14.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v3 3/3] i965: if DEBUG_OUT_OF_BOUND_CHK is up, check that noise padding for each bo used in batchbuffer is correct

2018-01-29 Thread Jason Ekstrand
On Mon, Jan 29, 2018 at 2:10 PM, Rogovin, Kevin 
wrote:

> Hi,
>
> Thanks, so the items that need to be fixed are:
>
>  Patch 1: use the better name for the macro value to better match the
> string
>  Patch 2: either use pread/pwrite for both set and check noise or use map
> for both (I will use map)
>

If you're going to use a map (which is fine), you don't need the "allocate
and return noise" function, you just need fill and check.


>  Patch 3: fine as is.
>

That about sums it up.


> Apparently, the mesa-dev archive is acting like /dev/null again as the
> patch series, your review and discussion have disappeared.
>

Weird...


> I will post a v4 shortly unless there are any additional shortcomings that
> need to be addressed.
>
> -Kevin
>
> -Original Message-
> From: Jason Ekstrand [mailto:ja...@jlekstrand.net]
> Sent: Monday, January 29, 2018 6:41 PM
> To: Rogovin, Kevin 
> Subject: RE: [PATCH v3 3/3] i965: if DEBUG_OUT_OF_BOUND_CHK is up, check
> that noise padding for each bo used in batchbuffer is correct
>
> Nope. That one looked fine as-is.
>
>
> On January 28, 2018 23:13:40 "Rogovin, Kevin" 
> wrote:
>
> > Any comments/review for Patch 3?
> >
> > -Original Message-
> > From: Rogovin, Kevin
> > Sent: Friday, January 26, 2018 10:56 AM
> > To: mesa-dev@lists.freedesktop.org
> > Cc: Rogovin, Kevin 
> > Subject: [PATCH v3 3/3] i965: if DEBUG_OUT_OF_BOUND_CHK is up, check
> > that noise padding for each bo used in batchbuffer is correct
> >
> > From: Kevin Rogovin 
> >
> > Signed-off-by: Kevin Rogovin 
> > ---
> >  src/mesa/drivers/dri/i965/intel_batchbuffer.c | 22
> > +-
> >  1 file changed, 21 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> > b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> > index 02bfd3f333..fc6998a7ca 100644
> > --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> > +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> > @@ -1019,11 +1019,31 @@ _intel_batchbuffer_flush_fence(struct
> > brw_context *brw,
> >
> > ret = submit_batch(brw, in_fence_fd, out_fence_fd);
> >
> > -   if (unlikely(INTEL_DEBUG & DEBUG_SYNC)) {
> > +   if (unlikely(INTEL_DEBUG & (DEBUG_SYNC | DEBUG_OUT_OF_BOUND_CHK)))
> > + {
> >fprintf(stderr, "waiting for idle\n");
> >brw_bo_wait_rendering(brw->batch.batch.bo);
> > }
> >
> > +   if (unlikely(INTEL_DEBUG & DEBUG_OUT_OF_BOUND_CHK)) {
> > +  bool detected_out_of_bounds_write = false;
> > +
> > +  for (int i = 0; i < brw->batch.exec_count; i++) {
> > + struct brw_bo *bo = brw->batch.exec_bos[i];
> > +
> > + if (!brw_bo_padding_is_good(bo)) {
> > +detected_out_of_bounds_write = true;
> > +fprintf(stderr,
> > +"Detected buffer out-of-bounds write from brw_bo %p
> "
> > +"(GEM %u, label = \"%s\")\n",
> > +bo, bo->gem_handle, bo->name);
> > + }
> > +  }
> > +
> > +  if (unlikely(detected_out_of_bounds_write)) {
> > + abort();
> > +  }
> > +   }
> > +
> > /* Start a new batch buffer. */
> > brw_new_batch(brw);
> >
> > --
> > 2.15.1
> >
>
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: shrink size of gl_array_attributes (v2)

2018-01-29 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Mon, Jan 29, 2018 at 11:22 PM, Brian Paul  wrote:
> Inspired by Marek's earlier patch, but even smaller.  Sort fields from
> largest to smallest.  Use bitfields for more fields (sometimes with an
> extra bit for MSVC).  Reduce Stride field to GLshort.
>
> Note that some fields cannot be bitfields because they're accessed via
> pointers (such as for glEnableClientState(GL_VERTEX_ARRAY) to set the
> Enabled field).
>
> Reduces size from 48 to 24 bytes.
> Also reduces size of gl_vertex_array_object from 3632 to 2864 bytes.
>
> And add some assertions in init_array().
>
> v2: use s/GLuint/unsigned/, improve commit comments.
> ---
>  src/mesa/main/arrayobj.c |  4 
>  src/mesa/main/mtypes.h   | 20 +++-
>  2 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
> index 1951638..7208f4c 100644
> --- a/src/mesa/main/arrayobj.c
> +++ b/src/mesa/main/arrayobj.c
> @@ -233,7 +233,9 @@ init_array(struct gl_context *ctx,
> struct gl_vertex_array_object *vao,
> gl_vert_attrib index, GLint size, GLint type)
>  {
> +   assert(index < ARRAY_SIZE(vao->VertexAttrib));
> struct gl_array_attributes *array = &vao->VertexAttrib[index];
> +   assert(index < ARRAY_SIZE(vao->BufferBinding));
> struct gl_vertex_buffer_binding *binding = &vao->BufferBinding[index];
>
> array->Size = size;
> @@ -247,6 +249,8 @@ init_array(struct gl_context *ctx,
> array->Integer = GL_FALSE;
> array->Doubles = GL_FALSE;
> array->_ElementSize = size * _mesa_sizeof_type(type);
> +   ASSERT_BITFIELD_SIZE(struct gl_array_attributes, BufferBindingIndex,
> +VERT_ATTRIB_MAX - 1);
> array->BufferBindingIndex = index;
>
> binding->Offset = 0;
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 329402a..dccc152 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -1528,19 +1528,21 @@ struct gl_vertex_array
>   */
>  struct gl_array_attributes
>  {
> -   GLint Size;  /**< Components per element (1,2,3,4) */
> +   /** Points to client array data. Not used when a VBO is bound */
> +   const GLubyte *Ptr;
> +   /** Offset of the first element relative to the binding offset */
> +   GLuint RelativeOffset;
> +   GLshort Stride;  /**< Stride as specified with gl*Pointer() */
> GLenum16 Type;   /**< Datatype: GL_FLOAT, GL_INT, etc */
> GLenum16 Format; /**< Default: GL_RGBA, but may be GL_BGRA */
> -   GLsizei Stride;  /**< Stride as specified with gl*Pointer() */
> -   const GLubyte *Ptr;  /**< Points to client array data. Not used when 
> a VBO is bound */
> -   GLintptr RelativeOffset; /**< Offset of the first element relative to the 
> binding offset */
> GLboolean Enabled;   /**< Whether the array is enabled */
> -   GLboolean Normalized;/**< Fixed-point values are normalized when 
> converted to floats */
> -   GLboolean Integer;   /**< Fixed-point values are not converted to 
> floats */
> -   GLboolean Doubles;   /**< double precision values are not converted 
> to floats */
> -   GLuint _ElementSize; /**< Size of each element in bytes */
> +   GLubyte Size;/**< Components per element (1,2,3,4) */
> +   unsigned Normalized:1;   /**< Fixed-point values are normalized when 
> converted to floats */
> +   unsigned Integer:1;  /**< Fixed-point values are not converted to 
> floats */
> +   unsigned Doubles:1;  /**< double precision values are not converted 
> to floats */
> +   unsigned _ElementSize:8; /**< Size of each element in bytes */
> /** Index into gl_vertex_array_object::BufferBinding[] array */
> -   GLuint BufferBindingIndex;
> +   unsigned BufferBindingIndex:6;
>  };
>
>
> --
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] mesa: shrink size of gl_array_attributes (v2)

2018-01-29 Thread Brian Paul
Inspired by Marek's earlier patch, but even smaller.  Sort fields from
largest to smallest.  Use bitfields for more fields (sometimes with an
extra bit for MSVC).  Reduce Stride field to GLshort.

Note that some fields cannot be bitfields because they're accessed via
pointers (such as for glEnableClientState(GL_VERTEX_ARRAY) to set the
Enabled field).

Reduces size from 48 to 24 bytes.
Also reduces size of gl_vertex_array_object from 3632 to 2864 bytes.

And add some assertions in init_array().

v2: use s/GLuint/unsigned/, improve commit comments.
---
 src/mesa/main/arrayobj.c |  4 
 src/mesa/main/mtypes.h   | 20 +++-
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 1951638..7208f4c 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -233,7 +233,9 @@ init_array(struct gl_context *ctx,
struct gl_vertex_array_object *vao,
gl_vert_attrib index, GLint size, GLint type)
 {
+   assert(index < ARRAY_SIZE(vao->VertexAttrib));
struct gl_array_attributes *array = &vao->VertexAttrib[index];
+   assert(index < ARRAY_SIZE(vao->BufferBinding));
struct gl_vertex_buffer_binding *binding = &vao->BufferBinding[index];
 
array->Size = size;
@@ -247,6 +249,8 @@ init_array(struct gl_context *ctx,
array->Integer = GL_FALSE;
array->Doubles = GL_FALSE;
array->_ElementSize = size * _mesa_sizeof_type(type);
+   ASSERT_BITFIELD_SIZE(struct gl_array_attributes, BufferBindingIndex,
+VERT_ATTRIB_MAX - 1);
array->BufferBindingIndex = index;
 
binding->Offset = 0;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 329402a..dccc152 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1528,19 +1528,21 @@ struct gl_vertex_array
  */
 struct gl_array_attributes
 {
-   GLint Size;  /**< Components per element (1,2,3,4) */
+   /** Points to client array data. Not used when a VBO is bound */
+   const GLubyte *Ptr;
+   /** Offset of the first element relative to the binding offset */
+   GLuint RelativeOffset;
+   GLshort Stride;  /**< Stride as specified with gl*Pointer() */
GLenum16 Type;   /**< Datatype: GL_FLOAT, GL_INT, etc */
GLenum16 Format; /**< Default: GL_RGBA, but may be GL_BGRA */
-   GLsizei Stride;  /**< Stride as specified with gl*Pointer() */
-   const GLubyte *Ptr;  /**< Points to client array data. Not used when a 
VBO is bound */
-   GLintptr RelativeOffset; /**< Offset of the first element relative to the 
binding offset */
GLboolean Enabled;   /**< Whether the array is enabled */
-   GLboolean Normalized;/**< Fixed-point values are normalized when 
converted to floats */
-   GLboolean Integer;   /**< Fixed-point values are not converted to 
floats */
-   GLboolean Doubles;   /**< double precision values are not converted to 
floats */
-   GLuint _ElementSize; /**< Size of each element in bytes */
+   GLubyte Size;/**< Components per element (1,2,3,4) */
+   unsigned Normalized:1;   /**< Fixed-point values are normalized when 
converted to floats */
+   unsigned Integer:1;  /**< Fixed-point values are not converted to 
floats */
+   unsigned Doubles:1;  /**< double precision values are not converted to 
floats */
+   unsigned _ElementSize:8; /**< Size of each element in bytes */
/** Index into gl_vertex_array_object::BufferBinding[] array */
-   GLuint BufferBindingIndex;
+   unsigned BufferBindingIndex:6;
 };
 
 
-- 
2.7.4

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


Re: [Mesa-dev] [PATCH] mesa: fix incorrect size/error test in _mesa_GetUnsignedBytevEXT()

2018-01-29 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Mon, Jan 29, 2018 at 10:42 PM, Brian Paul  wrote:
> get_value_size() returns -1 for an error.  The similar check in
> _mesa_GetUnsignedBytei_vEXT() is correct.
>
> Found by chance.  There are apparently no Piglit tests which exercise
> glGetUnsignedBytei_vEXT() or glGetUnsignedBytevEXT().
> ---
>  src/mesa/main/get.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
> index b41fdb2..04cab91 100644
> --- a/src/mesa/main/get.c
> +++ b/src/mesa/main/get.c
> @@ -2090,7 +2090,7 @@ _mesa_GetUnsignedBytevEXT(GLenum pname, GLubyte *data)
>
> d = find_value(func, pname, &p, &v);
> size = get_value_size(d->type, &v);
> -   if (size >= 0) {
> +   if (size <= 0) {
>_mesa_problem(ctx, "invalid value type in GetUnsignedBytevEXT()");
> }
>
> --
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] mesa: shrink size of gl_array_attribs

2018-01-29 Thread Marek Olšák
For the series:

Reviewed-by: Marek Olšák 

Marek

On Mon, Jan 29, 2018 at 10:38 PM, Brian Paul  wrote:
> Inspired by Marek's earlier patch, but even smaller.
> Sort fields from largest to smallest.  Use bitfields for more fields.
> Reduce Stride field to GLshort.
>
> Reduces size from 48 to 24 bytes.
> Also reduces size of gl_vertex_array_object from 3632 to 2864 bytes.
> ---
>  src/mesa/main/arrayobj.c |  4 
>  src/mesa/main/mtypes.h   | 20 +++-
>  2 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
> index 1951638..7208f4c 100644
> --- a/src/mesa/main/arrayobj.c
> +++ b/src/mesa/main/arrayobj.c
> @@ -233,7 +233,9 @@ init_array(struct gl_context *ctx,
> struct gl_vertex_array_object *vao,
> gl_vert_attrib index, GLint size, GLint type)
>  {
> +   assert(index < ARRAY_SIZE(vao->VertexAttrib));
> struct gl_array_attributes *array = &vao->VertexAttrib[index];
> +   assert(index < ARRAY_SIZE(vao->BufferBinding));
> struct gl_vertex_buffer_binding *binding = &vao->BufferBinding[index];
>
> array->Size = size;
> @@ -247,6 +249,8 @@ init_array(struct gl_context *ctx,
> array->Integer = GL_FALSE;
> array->Doubles = GL_FALSE;
> array->_ElementSize = size * _mesa_sizeof_type(type);
> +   ASSERT_BITFIELD_SIZE(struct gl_array_attributes, BufferBindingIndex,
> +VERT_ATTRIB_MAX - 1);
> array->BufferBindingIndex = index;
>
> binding->Offset = 0;
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 329402a..502f03c 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -1528,19 +1528,21 @@ struct gl_vertex_array
>   */
>  struct gl_array_attributes
>  {
> -   GLint Size;  /**< Components per element (1,2,3,4) */
> +   /** Points to client array data. Not used when a VBO is bound */
> +   const GLubyte *Ptr;
> +   /** Offset of the first element relative to the binding offset */
> +   GLuint RelativeOffset;
> +   GLshort Stride;  /**< Stride as specified with gl*Pointer() */
> GLenum16 Type;   /**< Datatype: GL_FLOAT, GL_INT, etc */
> GLenum16 Format; /**< Default: GL_RGBA, but may be GL_BGRA */
> -   GLsizei Stride;  /**< Stride as specified with gl*Pointer() */
> -   const GLubyte *Ptr;  /**< Points to client array data. Not used when 
> a VBO is bound */
> -   GLintptr RelativeOffset; /**< Offset of the first element relative to the 
> binding offset */
> GLboolean Enabled;   /**< Whether the array is enabled */
> -   GLboolean Normalized;/**< Fixed-point values are normalized when 
> converted to floats */
> -   GLboolean Integer;   /**< Fixed-point values are not converted to 
> floats */
> -   GLboolean Doubles;   /**< double precision values are not converted 
> to floats */
> -   GLuint _ElementSize; /**< Size of each element in bytes */
> +   GLubyte Size;/**< Components per element (1,2,3,4) */
> +   unsigned Normalized:1;   /**< Fixed-point values are normalized when 
> converted to floats */
> +   unsigned Integer:1;  /**< Fixed-point values are not converted to 
> floats */
> +   unsigned Doubles:1;  /**< double precision values are not converted 
> to floats */
> +   GLuint _ElementSize:8;   /**< Size of each element in bytes */
> /** Index into gl_vertex_array_object::BufferBinding[] array */
> -   GLuint BufferBindingIndex;
> +   GLuint BufferBindingIndex:6;
>  };
>
>
> --
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v3 3/3] i965: if DEBUG_OUT_OF_BOUND_CHK is up, check that noise padding for each bo used in batchbuffer is correct

2018-01-29 Thread Rogovin, Kevin
Hi,

Thanks, so the items that need to be fixed are:

 Patch 1: use the better name for the macro value to better match the string
 Patch 2: either use pread/pwrite for both set and check noise or use map for 
both (I will use map)
 Patch 3: fine as is.

Apparently, the mesa-dev archive is acting like /dev/null again as the patch 
series, your review and discussion have disappeared.

I will post a v4 shortly unless there are any additional shortcomings that need 
to be addressed.

-Kevin

-Original Message-
From: Jason Ekstrand [mailto:ja...@jlekstrand.net] 
Sent: Monday, January 29, 2018 6:41 PM
To: Rogovin, Kevin 
Subject: RE: [PATCH v3 3/3] i965: if DEBUG_OUT_OF_BOUND_CHK is up, check that 
noise padding for each bo used in batchbuffer is correct

Nope. That one looked fine as-is.


On January 28, 2018 23:13:40 "Rogovin, Kevin"  wrote:

> Any comments/review for Patch 3?
>
> -Original Message-
> From: Rogovin, Kevin
> Sent: Friday, January 26, 2018 10:56 AM
> To: mesa-dev@lists.freedesktop.org
> Cc: Rogovin, Kevin 
> Subject: [PATCH v3 3/3] i965: if DEBUG_OUT_OF_BOUND_CHK is up, check 
> that noise padding for each bo used in batchbuffer is correct
>
> From: Kevin Rogovin 
>
> Signed-off-by: Kevin Rogovin 
> ---
>  src/mesa/drivers/dri/i965/intel_batchbuffer.c | 22 
> +-
>  1 file changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> index 02bfd3f333..fc6998a7ca 100644
> --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> @@ -1019,11 +1019,31 @@ _intel_batchbuffer_flush_fence(struct 
> brw_context *brw,
>
> ret = submit_batch(brw, in_fence_fd, out_fence_fd);
>
> -   if (unlikely(INTEL_DEBUG & DEBUG_SYNC)) {
> +   if (unlikely(INTEL_DEBUG & (DEBUG_SYNC | DEBUG_OUT_OF_BOUND_CHK))) 
> + {
>fprintf(stderr, "waiting for idle\n");
>brw_bo_wait_rendering(brw->batch.batch.bo);
> }
>
> +   if (unlikely(INTEL_DEBUG & DEBUG_OUT_OF_BOUND_CHK)) {
> +  bool detected_out_of_bounds_write = false;
> +
> +  for (int i = 0; i < brw->batch.exec_count; i++) {
> + struct brw_bo *bo = brw->batch.exec_bos[i];
> +
> + if (!brw_bo_padding_is_good(bo)) {
> +detected_out_of_bounds_write = true;
> +fprintf(stderr,
> +"Detected buffer out-of-bounds write from brw_bo %p "
> +"(GEM %u, label = \"%s\")\n",
> +bo, bo->gem_handle, bo->name);
> + }
> +  }
> +
> +  if (unlikely(detected_out_of_bounds_write)) {
> + abort();
> +  }
> +   }
> +
> /* Start a new batch buffer. */
> brw_new_batch(brw);
>
> --
> 2.15.1
>


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


Re: [Mesa-dev] [PATCH 2/2] radeonsi: correctly parse disassembly with labels

2018-01-29 Thread Marek Olšák
For the series:

Reviewed-by: Marek Olšák 

Marek

On Tue, Jan 23, 2018 at 11:17 AM, Nicolai Hähnle  wrote:
> From: Nicolai Hähnle 
>
> LLVM now emits labels as part of the disassembly string, which is very
> useful but breaks the old parsing approach.
>
> Use the semicolon to detect the boundary of instructions instead of going
> by line breaks.
> ---
>  src/gallium/drivers/radeonsi/si_debug.c | 63 
> +
>  1 file changed, 32 insertions(+), 31 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_debug.c 
> b/src/gallium/drivers/radeonsi/si_debug.c
> index b24d5e705f5..8334c49a0ee 100644
> --- a/src/gallium/drivers/radeonsi/si_debug.c
> +++ b/src/gallium/drivers/radeonsi/si_debug.c
> @@ -23,20 +23,21 @@
>
>  #include "si_pipe.h"
>  #include "si_compute.h"
>  #include "sid.h"
>  #include "gfx9d.h"
>  #include "sid_tables.h"
>  #include "ddebug/dd_util.h"
>  #include "util/u_dump.h"
>  #include "util/u_log.h"
>  #include "util/u_memory.h"
> +#include "util/u_string.h"
>  #include "ac_debug.h"
>
>  static void si_dump_bo_list(struct si_context *sctx,
> const struct radeon_saved_cs *saved, FILE *f);
>
>  DEBUG_GET_ONCE_OPTION(replace_shaders, "RADEON_REPLACE_SHADERS", NULL)
>
>  static void si_dump_shader(struct si_screen *sscreen,
>enum pipe_shader_type processor,
>const struct si_shader *shader, FILE *f)
> @@ -783,56 +784,54 @@ static void si_dump_gfx_descriptors(struct si_context 
> *sctx,
>  static void si_dump_compute_descriptors(struct si_context *sctx,
> struct u_log_context *log)
>  {
> if (!sctx->cs_shader_state.program)
> return;
>
> si_dump_descriptors(sctx, PIPE_SHADER_COMPUTE, NULL, log);
>  }
>
>  struct si_shader_inst {
> -   char text[160];  /* one disasm line */
> -   unsigned offset; /* instruction offset */
> +   const char *text; /* start of disassembly for this instruction */
> +   unsigned textlen;
> unsigned size;   /* instruction size = 4 or 8 */
> +   uint64_t addr; /* instruction address */
>  };
>
> -/* Split a disassembly string into lines and add them to the array pointed
> - * to by "instructions". */
> +/**
> + * Split a disassembly string into instructions and add them to the array
> + * pointed to by \p instructions.
> + *
> + * Labels are considered to be part of the following instruction.
> + */
>  static void si_add_split_disasm(const char *disasm,
> -   uint64_t start_addr,
> +   uint64_t *addr,
> unsigned *num,
> struct si_shader_inst *instructions)
>  {
> -   struct si_shader_inst *last_inst = *num ? &instructions[*num - 1] : 
> NULL;
> -   char *next;
> +   const char *semicolon;
>
> -   while ((next = strchr(disasm, '\n'))) {
> -   struct si_shader_inst *inst = &instructions[*num];
> -   unsigned len = next - disasm;
> +   while ((semicolon = strchr(disasm, ';'))) {
> +   struct si_shader_inst *inst = &instructions[(*num)++];
> +   const char *end = util_strchrnul(semicolon, '\n');
>
> -   assert(len < ARRAY_SIZE(inst->text));
> -   memcpy(inst->text, disasm, len);
> -   inst->text[len] = 0;
> -   inst->offset = last_inst ? last_inst->offset + 
> last_inst->size : 0;
> +   inst->text = disasm;
> +   inst->textlen = end - disasm;
>
> -   const char *semicolon = strchr(disasm, ';');
> -   assert(semicolon);
> +   inst->addr = *addr;
> /* More than 16 chars after ";" means the instruction is 8 
> bytes long. */
> -   inst->size = next - semicolon > 16 ? 8 : 4;
> -
> -   snprintf(inst->text + len, ARRAY_SIZE(inst->text) - len,
> -   " [PC=0x%"PRIx64", off=%u, size=%u]",
> -   start_addr + inst->offset, inst->offset, inst->size);
> +   inst->size = end - semicolon > 16 ? 8 : 4;
> +   *addr += inst->size;
>
> -   last_inst = inst;
> -   (*num)++;
> -   disasm = next + 1;
> +   if (!(*end))
> +   break;
> +   disasm = end + 1;
> }
>  }
>
>  /* If the shader is being executed, print its asm instructions, and annotate
>   * those that are being executed right now with information about waves that
>   * execute them. This is most useful during a GPU hang.
>   */
>  static void si_print_annotated_shader(struct si_shader *shader,
>   struct ac_wave_info *waves,
>   unsigned num_waves,
> @@ -854,53 +853,55 @@ static void si_print_annotated_shader(struct si_shader 
> *shader,
> return; /* the shader

Re: [Mesa-dev] [PATCH 3/3] st/radeonsi: enable disk cache for nir

2018-01-29 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Wed, Jan 24, 2018 at 1:41 AM, Timothy Arceri  wrote:
> ---
>  src/gallium/drivers/radeonsi/si_pipe.c |  4 
>  src/mesa/state_tracker/st_program.c| 15 +++
>  2 files changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
> b/src/gallium/drivers/radeonsi/si_pipe.c
> index 676d199618..c096165b03 100644
> --- a/src/gallium/drivers/radeonsi/si_pipe.c
> +++ b/src/gallium/drivers/radeonsi/si_pipe.c
> @@ -621,10 +621,6 @@ static void si_disk_cache_create(struct si_screen 
> *sscreen)
> if (sscreen->debug_flags & DBG_ALL_SHADERS)
> return;
>
> -   /* TODO: remove this once gallium supports a nir cache */
> -   if (sscreen->debug_flags & DBG(NIR))
> -   return;
> -
> uint32_t mesa_timestamp;
> if (disk_cache_get_function_timestamp(si_disk_cache_create,
>   &mesa_timestamp)) {
> diff --git a/src/mesa/state_tracker/st_program.c 
> b/src/mesa/state_tracker/st_program.c
> index de9c5d1654..b3926eaa02 100644
> --- a/src/mesa/state_tracker/st_program.c
> +++ b/src/mesa/state_tracker/st_program.c
> @@ -466,6 +466,7 @@ st_translate_vertex_program(struct st_context *st,
>&stvp->tgsi.stream_output);
>}
>
> +  st_store_ir_in_disk_cache(st, &stvp->Base, true);
>return true;
> }
>
> @@ -900,9 +901,11 @@ st_translate_fragment_program(struct st_context *st,
>}
> }
>
> -   /* We have already compiler to NIR so just return */
> -   if (stfp->shader_program)
> +   /* We have already compiled to NIR so just return */
> +   if (stfp->shader_program) {
> +  st_store_ir_in_disk_cache(st, &stfp->Base, true);
>return true;
> +   }
>
> ureg = ureg_create_with_screen(PIPE_SHADER_FRAGMENT, st->pipe->screen);
> if (ureg == NULL)
> @@ -1472,6 +1475,7 @@ st_translate_geometry_program(struct st_context *st,
> /* We have already compiled to NIR so just return */
> if (stgp->shader_program) {
>st_translate_program_stream_output(&stgp->Base, 
> &stgp->tgsi.stream_output);
> +  st_store_ir_in_disk_cache(st, &stgp->Base, true);
>return true;
> }
>
> @@ -1571,8 +1575,10 @@ st_translate_tessctrl_program(struct st_context *st,
> struct ureg_program *ureg;
>
> /* We have already compiled to NIR so just return */
> -   if (sttcp->shader_program)
> +   if (sttcp->shader_program) {
> +  st_store_ir_in_disk_cache(st, &sttcp->Base, true);
>return true;
> +   }
>
> ureg = ureg_create_with_screen(PIPE_SHADER_TESS_CTRL, st->pipe->screen);
> if (ureg == NULL)
> @@ -1602,6 +1608,7 @@ st_translate_tesseval_program(struct st_context *st,
> /* We have already compiled to NIR so just return */
> if (sttep->shader_program) {
>st_translate_program_stream_output(&sttep->Base, 
> &sttep->tgsi.stream_output);
> +  st_store_ir_in_disk_cache(st, &sttep->Base, true);
>return true;
> }
>
> @@ -1652,7 +1659,7 @@ st_translate_compute_program(struct st_context *st,
>/* no compute variants: */
>st_finalize_nir(st, &stcp->Base, stcp->shader_program,
>(struct nir_shader *) stcp->tgsi.prog);
> -
> +  st_store_ir_in_disk_cache(st, &stcp->Base, true);
>return true;
> }
>
> --
> 2.14.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/3] st: add nir shader disk cache support

2018-01-29 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Wed, Jan 24, 2018 at 1:41 AM, Timothy Arceri  wrote:
> ---
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   2 +-
>  src/mesa/state_tracker/st_program.c|   6 +-
>  src/mesa/state_tracker/st_shader_cache.c   | 133 
> +++--
>  src/mesa/state_tracker/st_shader_cache.h   |   8 +-
>  4 files changed, 115 insertions(+), 34 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
> b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index f496bcfe59..e42405f2fa 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -6946,7 +6946,7 @@ st_link_shader(struct gl_context *ctx, struct 
> gl_shader_program *prog)
> }
>
> /* Return early if we are loading the shader from on-disk cache */
> -   if (st_load_tgsi_from_disk_cache(ctx, prog)) {
> +   if (st_load_ir_from_disk_cache(ctx, prog, use_nir)) {
>return GL_TRUE;
> }
>
> diff --git a/src/mesa/state_tracker/st_program.c 
> b/src/mesa/state_tracker/st_program.c
> index 1116b5afbc..de9c5d1654 100644
> --- a/src/mesa/state_tracker/st_program.c
> +++ b/src/mesa/state_tracker/st_program.c
> @@ -539,7 +539,7 @@ st_translate_vertex_program(struct st_context *st,
>
> if (stvp->glsl_to_tgsi) {
>stvp->glsl_to_tgsi = NULL;
> -  st_store_tgsi_in_disk_cache(st, &stvp->Base);
> +  st_store_ir_in_disk_cache(st, &stvp->Base, false);
> }
>
> return stvp->tgsi.tokens != NULL;
> @@ -996,7 +996,7 @@ st_translate_fragment_program(struct st_context *st,
>
> if (stfp->glsl_to_tgsi) {
>stfp->glsl_to_tgsi = NULL;
> -  st_store_tgsi_in_disk_cache(st, &stfp->Base);
> +  st_store_ir_in_disk_cache(st, &stfp->Base, false);
> }
>
> return stfp->tgsi.tokens != NULL;
> @@ -1412,7 +1412,7 @@ st_translate_program_common(struct st_context *st,
> outputMapping,
> &out_state->stream_output);
>
> -   st_store_tgsi_in_disk_cache(st, prog);
> +   st_store_ir_in_disk_cache(st, prog, false);
>
> if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
>_mesa_print_program(prog);
> diff --git a/src/mesa/state_tracker/st_shader_cache.c 
> b/src/mesa/state_tracker/st_shader_cache.c
> index a971b0d7ee..0f79a410a1 100644
> --- a/src/mesa/state_tracker/st_shader_cache.c
> +++ b/src/mesa/state_tracker/st_shader_cache.c
> @@ -26,6 +26,8 @@
>  #include "st_program.h"
>  #include "st_shader_cache.h"
>  #include "compiler/glsl/program.h"
> +#include "compiler/nir/nir.h"
> +#include "compiler/nir/nir_serialize.h"
>  #include "pipe/p_shader_tokens.h"
>  #include "program/ir_to_mesa.h"
>  #include "util/u_memory.h"
> @@ -44,20 +46,33 @@ write_stream_out_to_cache(struct blob *blob,
>  sizeof(tgsi->stream_output));
>  }
>
> +static void
> +copy_blob_to_driver_cache_blob(struct blob *blob, struct gl_program *prog)
> +{
> +   prog->driver_cache_blob = ralloc_size(NULL, blob->size);
> +   memcpy(prog->driver_cache_blob, blob->data, blob->size);
> +   prog->driver_cache_blob_size = blob->size;
> +}
> +
>  static void
>  write_tgsi_to_cache(struct blob *blob, const struct tgsi_token *tokens,
>  struct gl_program *prog, unsigned num_tokens)
>  {
> blob_write_uint32(blob, num_tokens);
> blob_write_bytes(blob, tokens, num_tokens * sizeof(struct tgsi_token));
> +   copy_blob_to_driver_cache_blob(blob, prog);
> +}
>
> -   prog->driver_cache_blob = ralloc_size(NULL, blob->size);
> -   memcpy(prog->driver_cache_blob, blob->data, blob->size);
> -   prog->driver_cache_blob_size = blob->size;
> +static void
> +write_nir_to_cache(struct blob *blob, struct gl_program *prog)
> +{
> +   nir_serialize(blob, prog->nir);
> +   copy_blob_to_driver_cache_blob(blob, prog);
>  }
>
> -void
> -st_serialise_tgsi_program(struct gl_context *ctx, struct gl_program *prog)
> +static void
> +st_serialise_ir_program(struct gl_context *ctx, struct gl_program *prog,
> +bool nir)
>  {
> struct blob blob;
> blob_init(&blob);
> @@ -73,8 +88,12 @@ st_serialise_tgsi_program(struct gl_context *ctx, struct 
> gl_program *prog)
> sizeof(stvp->result_to_output));
>
>write_stream_out_to_cache(&blob, &stvp->tgsi);
> -  write_tgsi_to_cache(&blob, stvp->tgsi.tokens, prog,
> -  stvp->num_tgsi_tokens);
> +
> +  if (nir)
> + write_nir_to_cache(&blob, prog);
> +  else
> + write_tgsi_to_cache(&blob, stvp->tgsi.tokens, prog,
> + stvp->num_tgsi_tokens);
>break;
> }
> case MESA_SHADER_TESS_CTRL:
> @@ -83,20 +102,29 @@ st_serialise_tgsi_program(struct gl_context *ctx, struct 
> gl_program *prog)
>struct st_common_program *stcp = (struct st_common_program *) prog;
>
>write_stream_out_to_cache(&blob, &stcp->tgsi);
> -  write_tgsi_to_cache(&blob, stcp->tgsi.tokens, prog,

[Mesa-dev] [PATCH] intel: Add Coffee Lake brand strings

2018-01-29 Thread Anuj Phogat
Signed-off-by: Anuj Phogat 
---
 include/pci_ids/i965_pci_ids.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/pci_ids/i965_pci_ids.h b/include/pci_ids/i965_pci_ids.h
index e947b026bd..feb9c582b1 100644
--- a/include/pci_ids/i965_pci_ids.h
+++ b/include/pci_ids/i965_pci_ids.h
@@ -170,11 +170,11 @@ CHIPSET(0x3E93, cfl_gt1, "Intel(R) HD Graphics 
(Coffeelake 2x6 GT1)")
 CHIPSET(0x3E99, cfl_gt1, "Intel(R) HD Graphics (Coffeelake 2x6 GT1)")
 CHIPSET(0x3EA1, cfl_gt1, "Intel(R) HD Graphics (Coffeelake 2x6 GT1)")
 CHIPSET(0x3EA4, cfl_gt1, "Intel(R) HD Graphics (Coffeelake 2x6 GT1)")
-CHIPSET(0x3E91, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)")
-CHIPSET(0x3E92, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)")
+CHIPSET(0x3E91, cfl_gt2, "Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2)")
+CHIPSET(0x3E92, cfl_gt2, "Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2)")
 CHIPSET(0x3E96, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)")
 CHIPSET(0x3E9A, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)")
-CHIPSET(0x3E9B, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)")
+CHIPSET(0x3E9B, cfl_gt2, "Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2)")
 CHIPSET(0x3E94, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)")
 CHIPSET(0x3EA0, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)")
 CHIPSET(0x3EA3, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)")
-- 
2.13.6

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


Re: [Mesa-dev] [PATCH] mesa: fix incorrect size/error test in _mesa_GetUnsignedBytevEXT()

2018-01-29 Thread Andres Rodriguez

Reviewed-by: Andres Rodriguez 

Thanks.

On 2018-01-29 04:42 PM, Brian Paul wrote:

get_value_size() returns -1 for an error.  The similar check in
_mesa_GetUnsignedBytei_vEXT() is correct.

Found by chance.  There are apparently no Piglit tests which exercise
glGetUnsignedBytei_vEXT() or glGetUnsignedBytevEXT().
---
  src/mesa/main/get.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index b41fdb2..04cab91 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -2090,7 +2090,7 @@ _mesa_GetUnsignedBytevEXT(GLenum pname, GLubyte *data)
  
 d = find_value(func, pname, &p, &v);

 size = get_value_size(d->type, &v);
-   if (size >= 0) {
+   if (size <= 0) {
_mesa_problem(ctx, "invalid value type in GetUnsignedBytevEXT()");
 }
  


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


Re: [Mesa-dev] [PATCH 1/3] st/glsl_to_tgsi: move nir detection earlier and set nir options

2018-01-29 Thread Marek Olšák
On Wed, Jan 24, 2018 at 1:41 AM, Timothy Arceri  wrote:
> We move the nir check before the shader cache call so that we can
> call a nir based caching function in a following patch.
> ---
>  src/mesa/state_tracker/st_glsl_to_nir.cpp  | 10 ++---
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 36 
> +++---
>  2 files changed, 30 insertions(+), 16 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
> b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> index 21b3640b2c..9e627be6da 100644
> --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> @@ -304,14 +304,8 @@ st_glsl_to_nir(struct st_context *st, struct gl_program 
> *prog,
> struct gl_shader_program *shader_program,
> gl_shader_stage stage)
>  {
> -   struct pipe_screen *pscreen = st->pipe->screen;
> -   enum pipe_shader_type ptarget = pipe_shader_type_from_mesa(stage);
> -   const nir_shader_compiler_options *options;
> -
> -   assert(pscreen->get_compiler_options);   /* drivers using NIR must 
> implement this */
> -
> -   options = (const nir_shader_compiler_options *)
> -  pscreen->get_compiler_options(pscreen, PIPE_SHADER_IR_NIR, ptarget);
> +   const nir_shader_compiler_options *options =
> +  st->ctx->Const.ShaderCompilerOptions[prog->info.stage].NirOptions;
> assert(options);
>
> if (prog->nir)
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
> b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index f44f02ad9d..f496bcfe59 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -6917,15 +6917,41 @@ extern "C" {
>  GLboolean
>  st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
>  {
> +   struct pipe_screen *pscreen = ctx->st->pipe->screen;
> +
> +   bool use_nir = false;
> +   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
> +  if (prog->_LinkedShaders[i] == NULL)
> + continue;
> +
> +  gl_shader_stage stage = prog->_LinkedShaders[i]->Stage;
> +  enum pipe_shader_type ptarget = pipe_shader_type_from_mesa(stage);
> +  enum pipe_shader_ir preferred_ir = (enum pipe_shader_ir)
> + pscreen->get_shader_param(pscreen, ptarget,
> +   PIPE_SHADER_CAP_PREFERRED_IR);
> +  use_nir = preferred_ir == PIPE_SHADER_IR_NIR;
> +
> +  if (use_nir) {
> + const nir_shader_compiler_options *options;
> +
> + /* drivers using NIR must implement this */
> + assert(pscreen->get_compiler_options);
> +
> + options = (const nir_shader_compiler_options *)
> +pscreen->get_compiler_options(pscreen, PIPE_SHADER_IR_NIR, 
> ptarget);
> + assert(options);
> +
> + ctx->Const.ShaderCompilerOptions[stage].NirOptions = options;

ctx->Const should be constant during the lifetime of the context. The
correct place for initializing ctx->Const is st_init_limits.

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


[Mesa-dev] [PATCH] mesa: fix incorrect size/error test in _mesa_GetUnsignedBytevEXT()

2018-01-29 Thread Brian Paul
get_value_size() returns -1 for an error.  The similar check in
_mesa_GetUnsignedBytei_vEXT() is correct.

Found by chance.  There are apparently no Piglit tests which exercise
glGetUnsignedBytei_vEXT() or glGetUnsignedBytevEXT().
---
 src/mesa/main/get.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index b41fdb2..04cab91 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -2090,7 +2090,7 @@ _mesa_GetUnsignedBytevEXT(GLenum pname, GLubyte *data)
 
d = find_value(func, pname, &p, &v);
size = get_value_size(d->type, &v);
-   if (size >= 0) {
+   if (size <= 0) {
   _mesa_problem(ctx, "invalid value type in GetUnsignedBytevEXT()");
}
 
-- 
2.7.4

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


Re: [Mesa-dev] [PATCH 2/2] st/shader_cache: restore num_tgsi_tokens when loading from cache

2018-01-29 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Fri, Jan 26, 2018 at 1:56 AM, Timothy Arceri  wrote:
> Without this we will fail to correctly serialise programs when
> using glGetProgramBinary() if the program was retrieved from
> the disk cache rather than freshly compiled.
>
> Fixes: c69b0dd6817b "st/glsl_to_tgsi: store num_tgsi_tokens in st_*_program"
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104762
> ---
>  src/mesa/state_tracker/st_shader_cache.c | 25 -
>  1 file changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_shader_cache.c 
> b/src/mesa/state_tracker/st_shader_cache.c
> index a971b0d7ee..92c633d450 100644
> --- a/src/mesa/state_tracker/st_shader_cache.c
> +++ b/src/mesa/state_tracker/st_shader_cache.c
> @@ -142,10 +142,11 @@ read_stream_out_from_cache(struct blob_reader 
> *blob_reader,
>
>  static void
>  read_tgsi_from_cache(struct blob_reader *blob_reader,
> - const struct tgsi_token **tokens)
> + const struct tgsi_token **tokens,
> + unsigned *num_tokens)
>  {
> -   uint32_t num_tokens  = blob_read_uint32(blob_reader);
> -   unsigned tokens_size = num_tokens * sizeof(struct tgsi_token);
> +   *num_tokens  = blob_read_uint32(blob_reader);
> +   unsigned tokens_size = *num_tokens * sizeof(struct tgsi_token);
> *tokens = (const struct tgsi_token*) MALLOC(tokens_size);
> blob_copy_bytes(blob_reader, (uint8_t *) *tokens, tokens_size);
>  }
> @@ -175,7 +176,8 @@ st_deserialise_tgsi_program(struct gl_context *ctx,
>sizeof(stvp->result_to_output));
>
>read_stream_out_from_cache(&blob_reader, &stvp->tgsi);
> -  read_tgsi_from_cache(&blob_reader, &stvp->tgsi.tokens);
> +  read_tgsi_from_cache(&blob_reader, &stvp->tgsi.tokens,
> +   &stvp->num_tgsi_tokens);
>
>if (st->vp == stvp)
>   st->dirty |= ST_NEW_VERTEX_PROGRAM(st, stvp);
> @@ -189,7 +191,8 @@ st_deserialise_tgsi_program(struct gl_context *ctx,
>  &sttcp->variants, &sttcp->tgsi);
>
>read_stream_out_from_cache(&blob_reader, &sttcp->tgsi);
> -  read_tgsi_from_cache(&blob_reader, &sttcp->tgsi.tokens);
> +  read_tgsi_from_cache(&blob_reader, &sttcp->tgsi.tokens,
> +   &sttcp->num_tgsi_tokens);
>
>if (st->tcp == sttcp)
>   st->dirty |= sttcp->affected_states;
> @@ -203,7 +206,8 @@ st_deserialise_tgsi_program(struct gl_context *ctx,
>  &sttep->variants, &sttep->tgsi);
>
>read_stream_out_from_cache(&blob_reader, &sttep->tgsi);
> -  read_tgsi_from_cache(&blob_reader, &sttep->tgsi.tokens);
> +  read_tgsi_from_cache(&blob_reader, &sttep->tgsi.tokens,
> +   &sttep->num_tgsi_tokens);
>
>if (st->tep == sttep)
>   st->dirty |= sttep->affected_states;
> @@ -217,7 +221,8 @@ st_deserialise_tgsi_program(struct gl_context *ctx,
>  &stgp->tgsi);
>
>read_stream_out_from_cache(&blob_reader, &stgp->tgsi);
> -  read_tgsi_from_cache(&blob_reader, &stgp->tgsi.tokens);
> +  read_tgsi_from_cache(&blob_reader, &stgp->tgsi.tokens,
> +   &stgp->num_tgsi_tokens);
>
>if (st->gp == stgp)
>   st->dirty |= stgp->affected_states;
> @@ -229,7 +234,8 @@ st_deserialise_tgsi_program(struct gl_context *ctx,
>
>st_release_fp_variants(st, stfp);
>
> -  read_tgsi_from_cache(&blob_reader, &stfp->tgsi.tokens);
> +  read_tgsi_from_cache(&blob_reader, &stfp->tgsi.tokens,
> +   &stfp->num_tgsi_tokens);
>
>if (st->fp == stfp)
>   st->dirty |= stfp->affected_states;
> @@ -242,7 +248,8 @@ st_deserialise_tgsi_program(struct gl_context *ctx,
>st_release_cp_variants(st, stcp);
>
>read_tgsi_from_cache(&blob_reader,
> -   (const struct tgsi_token**) &stcp->tgsi.prog);
> +   (const struct tgsi_token**) &stcp->tgsi.prog,
> +   &stcp->num_tgsi_tokens);
>
>stcp->tgsi.req_local_mem = stcp->Base.info.cs.shared_size;
>stcp->tgsi.req_private_mem = 0;
> --
> 2.14.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/2] mesa: shrink size of gl_array_attribs

2018-01-29 Thread Brian Paul
Inspired by Marek's earlier patch, but even smaller.
Sort fields from largest to smallest.  Use bitfields for more fields.
Reduce Stride field to GLshort.

Reduces size from 48 to 24 bytes.
Also reduces size of gl_vertex_array_object from 3632 to 2864 bytes.
---
 src/mesa/main/arrayobj.c |  4 
 src/mesa/main/mtypes.h   | 20 +++-
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 1951638..7208f4c 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -233,7 +233,9 @@ init_array(struct gl_context *ctx,
struct gl_vertex_array_object *vao,
gl_vert_attrib index, GLint size, GLint type)
 {
+   assert(index < ARRAY_SIZE(vao->VertexAttrib));
struct gl_array_attributes *array = &vao->VertexAttrib[index];
+   assert(index < ARRAY_SIZE(vao->BufferBinding));
struct gl_vertex_buffer_binding *binding = &vao->BufferBinding[index];
 
array->Size = size;
@@ -247,6 +249,8 @@ init_array(struct gl_context *ctx,
array->Integer = GL_FALSE;
array->Doubles = GL_FALSE;
array->_ElementSize = size * _mesa_sizeof_type(type);
+   ASSERT_BITFIELD_SIZE(struct gl_array_attributes, BufferBindingIndex,
+VERT_ATTRIB_MAX - 1);
array->BufferBindingIndex = index;
 
binding->Offset = 0;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 329402a..502f03c 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1528,19 +1528,21 @@ struct gl_vertex_array
  */
 struct gl_array_attributes
 {
-   GLint Size;  /**< Components per element (1,2,3,4) */
+   /** Points to client array data. Not used when a VBO is bound */
+   const GLubyte *Ptr;
+   /** Offset of the first element relative to the binding offset */
+   GLuint RelativeOffset;
+   GLshort Stride;  /**< Stride as specified with gl*Pointer() */
GLenum16 Type;   /**< Datatype: GL_FLOAT, GL_INT, etc */
GLenum16 Format; /**< Default: GL_RGBA, but may be GL_BGRA */
-   GLsizei Stride;  /**< Stride as specified with gl*Pointer() */
-   const GLubyte *Ptr;  /**< Points to client array data. Not used when a 
VBO is bound */
-   GLintptr RelativeOffset; /**< Offset of the first element relative to the 
binding offset */
GLboolean Enabled;   /**< Whether the array is enabled */
-   GLboolean Normalized;/**< Fixed-point values are normalized when 
converted to floats */
-   GLboolean Integer;   /**< Fixed-point values are not converted to 
floats */
-   GLboolean Doubles;   /**< double precision values are not converted to 
floats */
-   GLuint _ElementSize; /**< Size of each element in bytes */
+   GLubyte Size;/**< Components per element (1,2,3,4) */
+   unsigned Normalized:1;   /**< Fixed-point values are normalized when 
converted to floats */
+   unsigned Integer:1;  /**< Fixed-point values are not converted to 
floats */
+   unsigned Doubles:1;  /**< double precision values are not converted to 
floats */
+   GLuint _ElementSize:8;   /**< Size of each element in bytes */
/** Index into gl_vertex_array_object::BufferBinding[] array */
-   GLuint BufferBindingIndex;
+   GLuint BufferBindingIndex:6;
 };
 
 
-- 
2.7.4

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


[Mesa-dev] [PATCH 1/2] mesa: shrink gl_vertex_array

2018-01-29 Thread Brian Paul
Inspired by Marek's earlier patch, but goes a little further.
Sort fields from largest to smallest.  Use bitfields.

Reduced from 48 bytes to 32.  Also reduces size of gl_vertex_array_object
from 4144 to 3632
---
 src/mesa/main/mtypes.h | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 95f6319..329402a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1497,18 +1497,19 @@ struct gl_pixelstore_attrib
  */
 struct gl_vertex_array
 {
-   GLint Size;  /**< components per element (1,2,3,4) */
-   GLenum16 Type;   /**< datatype: GL_FLOAT, GL_INT, etc */
-   GLenum16 Format; /**< default: GL_RGBA, but may be GL_BGRA */
+   /** if NULL, vertex data are in user memory */
+   struct gl_buffer_object *BufferObj;
+   /** Pointer into user memory, or offset into the BufferObj */
+   const GLubyte *Ptr;
GLsizei StrideB;/**< actual stride in bytes */
-   GLuint _ElementSize; /**< size of each element in bytes */
-   const GLubyte *Ptr;  /**< Points to array data */
-   GLboolean Normalized;/**< GL_ARB_vertex_program */
-   GLboolean Integer;   /**< Integer-valued? */
-   GLboolean Doubles;   /**< double precision values are not converted to 
floats */
GLuint InstanceDivisor;  /**< GL_ARB_instanced_arrays */
-
-   struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */
+   GLenum16 Type;   /**< datatype: GL_FLOAT, GL_INT, etc */
+   GLenum16 Format; /**< default: GL_RGBA, but may be GL_BGRA */
+   unsigned Size:4; /**< components per element (1,2,3,4) */
+   unsigned _ElementSize:8; /**< in bytes, up to 4*sizeof(GLdouble) */
+   unsigned Normalized:1;   /**< GL_ARB_vertex_program */
+   unsigned Integer:1;  /**< Integer-valued? */
+   unsigned Doubles:1;  /**< doubles not converted to floats */
 };
 
 
-- 
2.7.4

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


Re: [Mesa-dev] [PATCH] st/glsl_to_nir: remove dead io after conversion to nir

2018-01-29 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Mon, Jan 29, 2018 at 7:36 AM, Timothy Arceri  wrote:
> This fixes an assert in nir_lower_var_copies() for some bioshock
> shaders where an unused clipdistance array has no size.
> ---
>  src/mesa/state_tracker/st_glsl_to_nir.cpp | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
> b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> index 02378bc796..34850fb88c 100644
> --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> @@ -313,6 +313,10 @@ st_glsl_to_nir(struct st_context *st, struct gl_program 
> *prog,
>
> nir_shader *nir = glsl_to_nir(shader_program, stage, options);
>
> +   nir_variable_mode mask =
> +  (nir_variable_mode) (nir_var_shader_in | nir_var_shader_out);
> +   nir_remove_dead_variables(nir, mask);
> +
> st_nir_opts(nir);
>
> return nir;
> --
> 2.14.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] st/glsl_to_nir: remove reallocation of sampler/image location

2018-01-29 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Tue, Jan 23, 2018 at 10:48 PM, Timothy Arceri  wrote:
> As far as I can tell this always just reassigns the same value.
>
> Also as we don't curretly store UniformHash in the shader cache
> removing this will help with adding a shader cache to gallium
> nir drivers.
> ---
>  src/mesa/state_tracker/st_glsl_to_nir.cpp | 8 
>  1 file changed, 8 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
> b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> index c7843cada5..21b3640b2c 100644
> --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> @@ -242,18 +242,10 @@ st_nir_assign_uniform_locations(struct gl_program *prog,
>   continue;
>
>if (uniform->type->is_sampler() || uniform->type->is_image()) {
> - unsigned val = 0;
> - bool found = shader_program->UniformHash->get(val, uniform->name);
>   if (uniform->type->is_sampler())
>  loc = shaderidx++;
>   else
>  loc = imageidx++;
> - assert(found);
> - (void) found; /* silence unused var warning */
> - /* this ensure that nir_lower_samplers looks at the correct
> -  * shader_program->UniformStorage[location]:
> -  */
> - uniform->data.location = val;
>} else if (strncmp(uniform->name, "gl_", 3) == 0) {
>   const gl_state_index *const stateTokens = (gl_state_index 
> *)uniform->state_slots[0].tokens;
>   /* This state reference has already been setup by ir_to_mesa, but 
> we'll
> --
> 2.14.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] ac: remove unused nir2llvmtype()

2018-01-29 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Mon, Jan 22, 2018 at 8:31 AM, Timothy Arceri  wrote:
> The last use of this was removed in the previous patch.
> ---
>  src/amd/common/ac_nir_to_llvm.c | 22 --
>  1 file changed, 22 deletions(-)
>
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index 1b4b877205..52c1f9ee20 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -158,28 +158,6 @@ nir_to_llvm_context_from_abi(struct ac_shader_abi *abi)
> return container_of(abi, ctx, abi);
>  }
>
> -static LLVMTypeRef
> -nir2llvmtype(struct ac_nir_context *ctx,
> -const struct glsl_type *type)
> -{
> -   switch (glsl_get_base_type(glsl_without_array(type))) {
> -   case GLSL_TYPE_UINT:
> -   case GLSL_TYPE_INT:
> -   return ctx->ac.i32;
> -   case GLSL_TYPE_UINT64:
> -   case GLSL_TYPE_INT64:
> -   return ctx->ac.i64;
> -   case GLSL_TYPE_DOUBLE:
> -   return ctx->ac.f64;
> -   case GLSL_TYPE_FLOAT:
> -   return ctx->ac.f32;
> -   default:
> -   assert(!"Unsupported type in nir2llvmtype()");
> -   break;
> -   }
> -   return 0;
> -}
> -
>  static LLVMValueRef get_sampler_desc(struct ac_nir_context *ctx,
>  const nir_deref_var *deref,
>  enum ac_descriptor_type desc_type,
> --
> 2.14.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] ac: fix gs load inputs type

2018-01-29 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Mon, Jan 22, 2018 at 8:31 AM, Timothy Arceri  wrote:
> This fixes the scenario where the input is a struct. With this
> the Unreal engines Elemental demo now works on radeonsi.
> ---
>  src/amd/common/ac_nir_to_llvm.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index 2c9b85bf82..1b4b877205 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -3189,16 +3189,17 @@ static LLVMValueRef visit_load_var(struct 
> ac_nir_context *ctx,
> }
>
> if (ctx->stage == MESA_SHADER_GEOMETRY) {
> +   LLVMTypeRef type = 
> LLVMIntTypeInContext(ctx->ac.context, instr->dest.ssa.bit_size);
> LLVMValueRef indir_index;
> unsigned const_index, vertex_index;
> get_deref_offset(ctx, instr->variables[0],
>  false, &vertex_index, NULL,
>  &const_index, &indir_index);
> +
> return ctx->abi->load_inputs(ctx->abi, 
> instr->variables[0]->var->data.location,
>  
> instr->variables[0]->var->data.driver_location,
>  
> instr->variables[0]->var->data.location_frac, ve,
> -vertex_index, 
> const_index,
> -nir2llvmtype(ctx, 
> instr->variables[0]->var->type));
> +vertex_index, 
> const_index, type);
> }
>
> for (unsigned chan = comp; chan < ve + comp; chan++) {
> --
> 2.14.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 7/8] radeonsi/nir: add input support for arrays that have not been copied to temps and split

2018-01-29 Thread Marek Olšák
For patches 2-3, 5-7:

Reviewed-by: Marek Olšák 

Marek

On Mon, Jan 15, 2018 at 4:46 AM, Timothy Arceri  wrote:
> We need this to be able to support the interpolateAt builtins in a
> sane way. It also leads to the generation of more optimal code.
> ---
>  src/gallium/drivers/radeonsi/si_shader_nir.c | 146 
> +++
>  1 file changed, 81 insertions(+), 65 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c 
> b/src/gallium/drivers/radeonsi/si_shader_nir.c
> index 32ac985bc7..a9e852c0bc 100644
> --- a/src/gallium/drivers/radeonsi/si_shader_nir.c
> +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
> @@ -259,7 +259,14 @@ void si_nir_scan_shader(const struct nir_shader *nir,
> unsigned num_inputs = 0;
> nir_foreach_variable(variable, &nir->inputs) {
> unsigned semantic_name, semantic_index;
> -   unsigned attrib_count = 
> glsl_count_attribute_slots(variable->type,
> +
> +   const struct glsl_type *type = variable->type;
> +   if (nir_is_per_vertex_io(variable, nir->info.stage)) {
> +   assert(glsl_type_is_array(type));
> +   type = glsl_get_array_element(type);
> +   }
> +
> +   unsigned attrib_count = glsl_count_attribute_slots(type,
>
> nir->info.stage == MESA_SHADER_VERTEX);
>
> /* Vertex shader inputs don't have semantics. The state
> @@ -274,9 +281,6 @@ void si_nir_scan_shader(const struct nir_shader *nir,
> continue;
> }
>
> -   assert(nir->info.stage != MESA_SHADER_FRAGMENT ||
> -  (attrib_count == 1 && "not implemented"));
> -
> /* Fragment shader position is a system value. */
> if (nir->info.stage == MESA_SHADER_FRAGMENT &&
> variable->data.location == VARYING_SLOT_POS) {
> @@ -289,63 +293,71 @@ void si_nir_scan_shader(const struct nir_shader *nir,
> }
>
> i = variable->data.driver_location;
> -   if (processed_inputs & ((uint64_t)1 << i))
> -   continue;
>
> -   processed_inputs |= ((uint64_t)1 << i);
> -   num_inputs++;
> +   for (unsigned j = 0; j < attrib_count; j++, i++) {
>
> -   tgsi_get_gl_varying_semantic(variable->data.location, true,
> -&semantic_name, &semantic_index);
> +   if (processed_inputs & ((uint64_t)1 << i)) {
> +//printf("continue %s %d\n", variable->name, variable->data.location + j);
> +   continue;
> +}
>
> -   info->input_semantic_name[i] = semantic_name;
> -   info->input_semantic_index[i] = semantic_index;
> +   processed_inputs |= ((uint64_t)1 << i);
> +   num_inputs++;
>
> -   if (variable->data.sample)
> -   info->input_interpolate_loc[i] = 
> TGSI_INTERPOLATE_LOC_SAMPLE;
> -   else if (variable->data.centroid)
> -   info->input_interpolate_loc[i] = 
> TGSI_INTERPOLATE_LOC_CENTROID;
> -   else
> -   info->input_interpolate_loc[i] = 
> TGSI_INTERPOLATE_LOC_CENTER;
> +//printf("in %s %d idx %d\n", variable->name, variable->data.location + j, 
> i);
>
> -   enum glsl_base_type base_type =
> -   
> glsl_get_base_type(glsl_without_array(variable->type));
> +   tgsi_get_gl_varying_semantic(variable->data.location 
> + j, true,
> +&semantic_name, 
> &semantic_index);
>
> -   switch (variable->data.interpolation) {
> -   case INTERP_MODE_NONE:
> -   if (glsl_base_type_is_integer(base_type)) {
> -   info->input_interpolate[i] = 
> TGSI_INTERPOLATE_CONSTANT;
> -   break;
> -   }
> +   info->input_semantic_name[i] = semantic_name;
> +   info->input_semantic_index[i] = semantic_index;
>
> -   if (semantic_name == TGSI_SEMANTIC_COLOR) {
> -   info->input_interpolate[i] = 
> TGSI_INTERPOLATE_COLOR;
> -   break;
> -   }
> -   /* fall-through */
> +   if (variable->data.sample)
> +   info->input_interpolate_loc[i] = 
> TGSI_INTERPOLATE_LOC_SAMPLE;
> +   else if (variable->data.centroid)
> +   info->input_interpolate_loc[i] = 
> TGSI_INTERPOLATE_LOC_CENTROID;
> +   else
> +   info->input_interpolate_loc[i] = 
> TGSI_INTERPOLATE_LOC_CENTE

Re: [Mesa-dev] [PATCH 8/8] st/glsl_to_nir: disable io lowering and forced indirect array splitting in fs

2018-01-29 Thread Marek Olšák
On Mon, Jan 15, 2018 at 4:46 AM, Timothy Arceri  wrote:
> We need this to be able to support the interpolateAt builtins in a
> sane way. It also leads to the generation of more optimal code.
>
> The lowering and splitting is made conditional on glsl 400 because
> vc4 and freedreno both expect these passes to be enabled and niether
> support glsl 400 so don't need to deal with the interpolateAt builtins.
>
> We leave the other stages for now as to avoid regressions.
> ---
>  src/mesa/state_tracker/st_glsl_to_nir.cpp | 13 +++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
> b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> index 6e3a1548f4..bc55c5b7db 100644
> --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> @@ -461,7 +461,9 @@ st_nir_get_mesa_program(struct gl_context *ctx,
>  struct gl_linked_shader *shader)
>  {
> struct st_context *st = st_context(ctx);
> +   struct pipe_screen *screen = st->pipe->screen;
> struct gl_program *prog;
> +   unsigned glsl_version = screen->get_param(screen, 
> PIPE_CAP_GLSL_FEATURE_LEVEL);
>
> validate_ir_tree(shader->ir);
>
> @@ -491,11 +493,14 @@ st_nir_get_mesa_program(struct gl_context *ctx,
> prog->nir = nir;
>
> if (nir->info.stage != MESA_SHADER_TESS_CTRL &&
> -   nir->info.stage != MESA_SHADER_TESS_EVAL) {
> +   nir->info.stage != MESA_SHADER_TESS_EVAL &&
> +   (nir->info.stage != MESA_SHADER_FRAGMENT ||
> +(glsl_version < 400 && nir->info.stage == MESA_SHADER_FRAGMENT))) {

SInce it's clear we don't want that pass in a lot of cases, you could
just replace the whole conditional with:
if (glsl_version < 400) {

>NIR_PASS_V(nir, nir_lower_io_to_temporaries,
>   nir_shader_get_entrypoint(nir),
>   true, true);
> }
> +
> NIR_PASS_V(nir, nir_lower_global_vars_to_local);
> NIR_PASS_V(nir, nir_split_var_copies);
> NIR_PASS_V(nir, nir_lower_var_copies);
> @@ -665,12 +670,16 @@ st_finalize_nir(struct st_context *st, struct 
> gl_program *prog,
>  struct gl_shader_program *shader_program, nir_shader *nir)
>  {
> struct pipe_screen *screen = st->pipe->screen;
> +   unsigned glsl_version = screen->get_param(screen, 
> PIPE_CAP_GLSL_FEATURE_LEVEL);
>
> NIR_PASS_V(nir, nir_split_var_copies);
> NIR_PASS_V(nir, nir_lower_var_copies);
> if (nir->info.stage != MESA_SHADER_TESS_CTRL &&
> -   nir->info.stage != MESA_SHADER_TESS_EVAL)
> +   nir->info.stage != MESA_SHADER_TESS_EVAL &&
> +   (nir->info.stage != MESA_SHADER_FRAGMENT ||
> +(glsl_version < 400 && nir->info.stage == MESA_SHADER_FRAGMENT))) {

Same here.

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


Re: [Mesa-dev] [PATCH shaderdb 2/3] run: fallback to 3.1 core context

2018-01-29 Thread Matt Turner
On Mon, Jan 29, 2018 at 12:08 PM, Rob Clark  wrote:
> On Mon, Jan 29, 2018 at 2:39 PM, Ilia Mirkin  wrote:
>> On Mon, Jan 29, 2018 at 2:26 PM, Rob Clark  wrote:
>>> If we can't create a 3.2 core context, fall back to a 3.1 context.
>>> ---
>>>  run.c | 17 +++--
>>>  1 file changed, 15 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/run.c b/run.c
>>> index 79d771e..2056ebd 100644
>>> --- a/run.c
>>> +++ b/run.c
>>> @@ -383,9 +383,22 @@ create_context(EGLDisplay egl_dpy, EGLConfig cfg, enum 
>>> shader_type type)
>>>  EGL_NONE
>>>  };
>>>  switch (type) {
>>> -case TYPE_CORE:
>>> +case TYPE_CORE: {
>>>  eglBindAPI(EGL_OPENGL_API);
>>> -return eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
>>> +EGLContext core_ctx =
>>> +eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
>>> +
>>> +if (core_ctx == EGL_NO_CONTEXT) {
>>> +static const EGLint attribs_31[] = {
>>> +EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
>>> +EGL_CONTEXT_MINOR_VERSION_KHR, 1,
>>> +EGL_NONE
>>> +};
>>> +core_ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, 
>>> attribs_31);
>>
>> Should ensure that this context does not expose GL_ARB_compatibility.
>> Otherwise it's a compat-type context.
>>
>
> Hmm, does that mean there is no way to create a 3.1 core profile if a
> driver supports 3.1 compat?

As far as I know, yes, that's the case. Kinda nuts.

> btw, I wonder how much we really care.. afaict all this core/compat
> logic in shader-db runner must just be to avoid using a core context
> for shaders asking for glsl version <= 130 (presumably in case they
> use features removed from core).  So I guess it doesn't really matter
> if we ended up with a 3.1 compat profile.

Yeah, for our purposes I think just asking for a 3.1 profile and not
caring about what you get is fine.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH shaderdb 2/3] run: fallback to 3.1 core context

2018-01-29 Thread Adam Jackson
On Mon, 2018-01-29 at 15:08 -0500, Rob Clark wrote:

> Hmm, does that mean there is no way to create a 3.1 core profile if a
> driver supports 3.1 compat?

This is where the "forward-compatible" bit matters, iirc. If you ask
for 3.1FC you shouldn't get ARB_compatibility.

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


[Mesa-dev] [PATCH 7/8] mesa: rename some 'client' array functions

2018-01-29 Thread Brian Paul
A long time ago gl_vertex_array was gl_client_array.  Update some function
names to be consistent.
---
 src/mesa/main/arrayobj.c | 6 +++---
 src/mesa/main/arrayobj.h | 4 ++--
 src/mesa/main/attrib.c   | 2 +-
 src/mesa/main/state.c| 2 +-
 src/mesa/main/varray.c   | 4 ++--
 src/mesa/main/varray.h   | 4 ++--
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index b862f0f..ea9b316 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -311,8 +311,8 @@ _mesa_initialize_vao(struct gl_context *ctx,
  * or a gl_vertex_buffer_binding has changed.
  */
 void
-_mesa_update_vao_client_arrays(struct gl_context *ctx,
-   struct gl_vertex_array_object *vao)
+_mesa_update_vao_derived_arrays(struct gl_context *ctx,
+struct gl_vertex_array_object *vao)
 {
GLbitfield arrays = vao->NewArrays;
 
@@ -324,7 +324,7 @@ _mesa_update_vao_client_arrays(struct gl_context *ctx,
   const struct gl_vertex_buffer_binding *buffer_binding =
  &vao->BufferBinding[attrib_array->BufferBindingIndex];
 
-  _mesa_update_client_array(ctx, client_array, attrib_array,
+  _mesa_update_vertex_array(ctx, client_array, attrib_array,
 buffer_binding);
}
 }
diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
index 1b9900c..ff26157 100644
--- a/src/mesa/main/arrayobj.h
+++ b/src/mesa/main/arrayobj.h
@@ -78,8 +78,8 @@ _mesa_initialize_vao(struct gl_context *ctx,
 
 
 extern void
-_mesa_update_vao_client_arrays(struct gl_context *ctx,
-   struct gl_vertex_array_object *vao);
+_mesa_update_vao_derived_arrays(struct gl_context *ctx,
+struct gl_vertex_array_object *vao);
 
 /* Returns true if all varying arrays reside in vbos */
 extern bool
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 3c12fd6..0b4b63f 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1503,7 +1503,7 @@ copy_array_object(struct gl_context *ctx,
/* skip RefCount */
 
for (i = 0; i < ARRAY_SIZE(src->VertexAttrib); i++) {
-  _mesa_copy_client_array(ctx, &dest->_VertexAttrib[i], 
&src->_VertexAttrib[i]);
+  _mesa_copy_vertex_array(ctx, &dest->_VertexAttrib[i], 
&src->_VertexAttrib[i]);
   _mesa_copy_vertex_attrib_array(ctx, &dest->VertexAttrib[i], 
&src->VertexAttrib[i]);
   _mesa_copy_vertex_buffer_binding(ctx, &dest->BufferBinding[i], 
&src->BufferBinding[i]);
}
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index dd61cc7..df694d0 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -357,7 +357,7 @@ _mesa_update_state_locked( struct gl_context *ctx )
}
 
if (new_state & _NEW_ARRAY)
-  _mesa_update_vao_client_arrays(ctx, ctx->Array.VAO);
+  _mesa_update_vao_derived_arrays(ctx, ctx->Array.VAO);
 
  out:
new_prog_state |= update_program_constants(ctx);
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 2801a6f..6c022b4 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -2794,10 +2794,10 @@ _mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint 
bindingIndex,
 
 
 /**
- * Copy one client vertex array to another.
+ * Copy one vertex array to another.
  */
 void
-_mesa_copy_client_array(struct gl_context *ctx,
+_mesa_copy_vertex_array(struct gl_context *ctx,
 struct gl_vertex_array *dst,
 struct gl_vertex_array *src)
 {
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 19506bf..79ecd9a 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -53,7 +53,7 @@ _mesa_vertex_attrib_address(const struct gl_array_attributes 
*array,
  * gl_array_attributes and a gl_vertex_buffer_binding.
  */
 static inline void
-_mesa_update_client_array(struct gl_context *ctx,
+_mesa_update_vertex_array(struct gl_context *ctx,
   struct gl_vertex_array *dst,
   const struct gl_array_attributes *attribs,
   const struct gl_vertex_buffer_binding *binding)
@@ -475,7 +475,7 @@ _mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint 
bindingIndex,
 GLuint divisor);
 
 extern void
-_mesa_copy_client_array(struct gl_context *ctx,
+_mesa_copy_vertex_array(struct gl_context *ctx,
 struct gl_vertex_array *dst,
 struct gl_vertex_array *src);
 
-- 
2.7.4

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


[Mesa-dev] [PATCH 8/8] mesa: use gl_vert_attrib enum type in more places

2018-01-29 Thread Brian Paul
Slightly better readbility.
---
 src/mesa/main/arrayobj.c |  2 +-
 src/mesa/main/varray.c   | 12 ++--
 src/mesa/main/varray.h   |  4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index ea9b316..1951638 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -231,7 +231,7 @@ _mesa_reference_vao_(struct gl_context *ctx,
 static void
 init_array(struct gl_context *ctx,
struct gl_vertex_array_object *vao,
-   GLuint index, GLint size, GLint type)
+   gl_vert_attrib index, GLint size, GLint type)
 {
struct gl_array_attributes *array = &vao->VertexAttrib[index];
struct gl_vertex_buffer_binding *binding = &vao->BufferBinding[index];
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 6c022b4..b2783e2 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -132,7 +132,7 @@ type_to_bit(const struct gl_context *ctx, GLenum type)
 static void
 vertex_attrib_binding(struct gl_context *ctx,
   struct gl_vertex_array_object *vao,
-  GLuint attribIndex,
+  gl_vert_attrib attribIndex,
   GLuint bindingIndex)
 {
struct gl_array_attributes *array = &vao->VertexAttrib[attribIndex];
@@ -294,7 +294,7 @@ get_array_format(const struct gl_context *ctx, GLint 
sizeMax, GLint *size)
 void
 _mesa_update_array_format(struct gl_context *ctx,
   struct gl_vertex_array_object *vao,
-  GLuint attrib, GLint size, GLenum type,
+  gl_vert_attrib attrib, GLint size, GLenum type,
   GLenum format, GLboolean normalized,
   GLboolean integer, GLboolean doubles,
   GLuint relativeOffset)
@@ -1063,7 +1063,7 @@ _mesa_VertexAttribLPointer(GLuint index, GLint size, 
GLenum type,
 void
 _mesa_enable_vertex_array_attrib(struct gl_context *ctx,
  struct gl_vertex_array_object *vao,
- unsigned attrib)
+ gl_vert_attrib attrib)
 {
assert(attrib >= VERT_ATTRIB_GENERIC0);
assert(attrib < ARRAY_SIZE(vao->VertexAttrib));
@@ -1965,7 +1965,7 @@ _mesa_VertexAttribDivisor_no_error(GLuint index, GLuint 
divisor)
 {
GET_CURRENT_CONTEXT(ctx);
 
-   const GLuint genericIndex = VERT_ATTRIB_GENERIC(index);
+   const gl_vert_attrib genericIndex = VERT_ATTRIB_GENERIC(index);
struct gl_vertex_array_object * const vao = ctx->Array.VAO;
 
assert(genericIndex < ARRAY_SIZE(vao->VertexAttrib));
@@ -1996,7 +1996,7 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor)
 {
GET_CURRENT_CONTEXT(ctx);
 
-   const GLuint genericIndex = VERT_ATTRIB_GENERIC(index);
+   const gl_vert_attrib genericIndex = VERT_ATTRIB_GENERIC(index);
struct gl_vertex_array_object * const vao = ctx->Array.VAO;
 
if (!ctx->Extensions.ARB_instanced_arrays) {
@@ -2856,7 +2856,7 @@ _mesa_print_arrays(struct gl_context *ctx)
 
fprintf(stderr, "Array Object %u\n", vao->Name);
 
-   unsigned i;
+   gl_vert_attrib i;
for (i = 0; i < VERT_ATTRIB_MAX; ++i) {
   const struct gl_array_attributes *array = &vao->VertexAttrib[i];
   if (!array->Enabled)
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 79ecd9a..fe7eb81 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -96,7 +96,7 @@ _mesa_set_drawing_arrays(struct gl_context *ctx,
 extern void
 _mesa_update_array_format(struct gl_context *ctx,
   struct gl_vertex_array_object *vao,
-  GLuint attrib, GLint size, GLenum type,
+  gl_vert_attrib attrib, GLint size, GLenum type,
   GLenum format, GLboolean normalized,
   GLboolean integer, GLboolean doubles,
   GLuint relativeOffset);
@@ -104,7 +104,7 @@ _mesa_update_array_format(struct gl_context *ctx,
 extern void
 _mesa_enable_vertex_array_attrib(struct gl_context *ctx,
  struct gl_vertex_array_object *vao,
- unsigned attrib);
+ gl_vert_attrib attrib);
 
 extern void
 _mesa_bind_vertex_buffer(struct gl_context *ctx,
-- 
2.7.4

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


[Mesa-dev] [PATCH 1/8] mesa: rename some vars in client_state()

2018-01-29 Thread Brian Paul
---
 src/mesa/main/enable.c | 50 +-
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index c859a7a..0b3de52 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -64,46 +64,46 @@ static void
 client_state(struct gl_context *ctx, GLenum cap, GLboolean state)
 {
struct gl_vertex_array_object *vao = ctx->Array.VAO;
-   GLbitfield flag;
-   GLboolean *var;
+   GLbitfield vert_attrib_bit;
+   GLboolean *enable_var;
 
switch (cap) {
   case GL_VERTEX_ARRAY:
- var = &vao->VertexAttrib[VERT_ATTRIB_POS].Enabled;
- flag = VERT_BIT_POS;
+ enable_var = &vao->VertexAttrib[VERT_ATTRIB_POS].Enabled;
+ vert_attrib_bit = VERT_BIT_POS;
  break;
   case GL_NORMAL_ARRAY:
- var = &vao->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled;
- flag = VERT_BIT_NORMAL;
+ enable_var = &vao->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled;
+ vert_attrib_bit = VERT_BIT_NORMAL;
  break;
   case GL_COLOR_ARRAY:
- var = &vao->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled;
- flag = VERT_BIT_COLOR0;
+ enable_var = &vao->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled;
+ vert_attrib_bit = VERT_BIT_COLOR0;
  break;
   case GL_INDEX_ARRAY:
- var = &vao->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled;
- flag = VERT_BIT_COLOR_INDEX;
+ enable_var = &vao->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled;
+ vert_attrib_bit = VERT_BIT_COLOR_INDEX;
  break;
   case GL_TEXTURE_COORD_ARRAY:
- var = 
&vao->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Enabled;
- flag = VERT_BIT_TEX(ctx->Array.ActiveTexture);
+ enable_var = 
&vao->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Enabled;
+ vert_attrib_bit = VERT_BIT_TEX(ctx->Array.ActiveTexture);
  break;
   case GL_EDGE_FLAG_ARRAY:
- var = &vao->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled;
- flag = VERT_BIT_EDGEFLAG;
+ enable_var = &vao->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled;
+ vert_attrib_bit = VERT_BIT_EDGEFLAG;
  break;
   case GL_FOG_COORDINATE_ARRAY_EXT:
- var = &vao->VertexAttrib[VERT_ATTRIB_FOG].Enabled;
- flag = VERT_BIT_FOG;
+ enable_var = &vao->VertexAttrib[VERT_ATTRIB_FOG].Enabled;
+ vert_attrib_bit = VERT_BIT_FOG;
  break;
   case GL_SECONDARY_COLOR_ARRAY_EXT:
- var = &vao->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled;
- flag = VERT_BIT_COLOR1;
+ enable_var = &vao->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled;
+ vert_attrib_bit = VERT_BIT_COLOR1;
  break;
 
   case GL_POINT_SIZE_ARRAY_OES:
- var = &vao->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled;
- flag = VERT_BIT_POINT_SIZE;
+ enable_var = &vao->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled;
+ vert_attrib_bit = VERT_BIT_POINT_SIZE;
  FLUSH_VERTICES(ctx, _NEW_PROGRAM);
  ctx->VertexProgram.PointSizeEnabled = state;
  break;
@@ -124,19 +124,19 @@ client_state(struct gl_context *ctx, GLenum cap, 
GLboolean state)
  goto invalid_enum_error;
}
 
-   if (*var == state)
+   if (*enable_var == state)
   return;
 
FLUSH_VERTICES(ctx, _NEW_ARRAY);
 
-   *var = state;
+   *enable_var = state;
 
if (state)
-  vao->_Enabled |= flag;
+  vao->_Enabled |= vert_attrib_bit;
else
-  vao->_Enabled &= ~flag;
+  vao->_Enabled &= ~vert_attrib_bit;
 
-   vao->NewArrays |= flag;
+   vao->NewArrays |= vert_attrib_bit;
 
if (ctx->Driver.Enable) {
   ctx->Driver.Enable( ctx, cap, state );
-- 
2.7.4

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


[Mesa-dev] [PATCH 5/8] mesa: check/assert array index in _mesa_bind_vertex_buffer()

2018-01-29 Thread Brian Paul
---
 src/mesa/main/varray.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index bda1c5a..2801a6f 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -166,6 +166,7 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
  struct gl_buffer_object *vbo,
  GLintptr offset, GLsizei stride)
 {
+   assert(index < ARRAY_SIZE(vao->BufferBinding));
struct gl_vertex_buffer_binding *binding = &vao->BufferBinding[index];
 
if (binding->BufferObj != vbo ||
-- 
2.7.4

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


[Mesa-dev] [PATCH 2/8] mesa: add an assertion in _mesa_enable_vertex_array_attrib()

2018-01-29 Thread Brian Paul
Some of the enable/disable vertex array functions take a zero-based
generic index, while others take a VERT_ATTRIB_GENERIC0-based value.
Add an assertion to clarify that in one place.
---
 src/mesa/main/varray.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 31f1c83..bda1c5a 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1064,6 +1064,7 @@ _mesa_enable_vertex_array_attrib(struct gl_context *ctx,
  struct gl_vertex_array_object *vao,
  unsigned attrib)
 {
+   assert(attrib >= VERT_ATTRIB_GENERIC0);
assert(attrib < ARRAY_SIZE(vao->VertexAttrib));
 
if (!vao->VertexAttrib[attrib].Enabled) {
-- 
2.7.4

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


[Mesa-dev] [PATCH 6/8] mesa: s/src/attribs/ in _mesa_update_client_array()

2018-01-29 Thread Brian Paul
---
 src/mesa/main/varray.h | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 93f2f47..19506bf 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -55,19 +55,19 @@ _mesa_vertex_attrib_address(const struct 
gl_array_attributes *array,
 static inline void
 _mesa_update_client_array(struct gl_context *ctx,
   struct gl_vertex_array *dst,
-  const struct gl_array_attributes *src,
+  const struct gl_array_attributes *attribs,
   const struct gl_vertex_buffer_binding *binding)
 {
-   dst->Size = src->Size;
-   dst->Type = src->Type;
-   dst->Format = src->Format;
+   dst->Size = attribs->Size;
+   dst->Type = attribs->Type;
+   dst->Format = attribs->Format;
dst->StrideB = binding->Stride;
-   dst->Ptr = _mesa_vertex_attrib_address(src, binding);
-   dst->Normalized = src->Normalized;
-   dst->Integer = src->Integer;
-   dst->Doubles = src->Doubles;
+   dst->Ptr = _mesa_vertex_attrib_address(attribs, binding);
+   dst->Normalized = attribs->Normalized;
+   dst->Integer = attribs->Integer;
+   dst->Doubles = attribs->Doubles;
dst->InstanceDivisor = binding->InstanceDivisor;
-   dst->_ElementSize = src->_ElementSize;
+   dst->_ElementSize = attribs->_ElementSize;
_mesa_reference_buffer_object(ctx, &dst->BufferObj, binding->BufferObj);
 }
 
-- 
2.7.4

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


[Mesa-dev] [PATCH 3/8] mesa: trivial comment typo fix in arrayobj.c

2018-01-29 Thread Brian Paul
---
 src/mesa/main/arrayobj.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 2810647..b862f0f 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -222,7 +222,7 @@ _mesa_reference_vao_(struct gl_context *ctx,
 
 
 /**
- * Initialize attribtes of a vertex array within a vertex array object.
+ * Initialize attributes of a vertex array within a vertex array object.
  * \param vao  the container vertex array object
  * \param index  which array in the VAO to initialize
  * \param size  number of components (1, 2, 3 or 4) per attribute
-- 
2.7.4

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


[Mesa-dev] [PATCH 4/8] mesa: improve comment for gl_array_attributes::BufferBindingIndex

2018-01-29 Thread Brian Paul
---
 src/mesa/main/mtypes.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b0eeeaf..95f6319 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1538,7 +1538,8 @@ struct gl_array_attributes
GLboolean Integer;   /**< Fixed-point values are not converted to 
floats */
GLboolean Doubles;   /**< double precision values are not converted to 
floats */
GLuint _ElementSize; /**< Size of each element in bytes */
-   GLuint BufferBindingIndex;/**< Vertex buffer binding */
+   /** Index into gl_vertex_array_object::BufferBinding[] array */
+   GLuint BufferBindingIndex;
 };
 
 
-- 
2.7.4

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


Re: [Mesa-dev] [PATCH] r600/sb: Force ELSE path if the byte code started off with it

2018-01-29 Thread Dave Airlie
On 30 January 2018 at 06:25, Gert Wollny  wrote:
> Am Montag, den 29.01.2018, 20:32 +0100 schrieb Roland Scheidegger:
>>
>> Am I correct assuming that for something like
>>while (foo) {
>>   if (bar) {
>>  do something;
>>   } else {
>>  /* nothing */
>>   }
>>}
>> The else clause wouldn't get optimized away neither?
>> (This of course is a trivial example, but I suppose it would extend
>> to cases where the optimizer actually optimized away the alu
>> instructions in the else clause).
>> In this case, this indeed looks rather harsh.
> This is indeed the case (unless the if is eliminated completely in the
> if_conversion).
>
>> I would have said in theory somehow the break should be some op which
>> (despite not having a dst) has side-effects so it would not be
>> subject to elimination somewhere (as there would be a if->next node
>> in this case then).
> It is the else that vanishes, but only if there is only a break in the
> else path, if there there is also an ALU clause, then the else branch
> is created propperly.
>
>> Albeit I'm completely oblivious how it really gets optimized away, is
>> that based on liveness analysis or something? The sb code is a
>> mystery to me...
> I'm trying to understand it, but is is very dificult to grasp how it
> works even with the debugging output. Well, maybe Dave has a better
> idea.
>

I'm reading the paper the whole depart region stuff is based on today,
maybe I'll come out enlightened or more confused.

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


Re: [Mesa-dev] [PATCH] r600/sb: Force ELSE path if the byte code started off with it

2018-01-29 Thread Gert Wollny
Am Montag, den 29.01.2018, 20:32 +0100 schrieb Roland Scheidegger:
> 
> Am I correct assuming that for something like
>while (foo) {
>   if (bar) {
>  do something;
>   } else {
>  /* nothing */
>   }
>}
> The else clause wouldn't get optimized away neither?
> (This of course is a trivial example, but I suppose it would extend
> to cases where the optimizer actually optimized away the alu
> instructions in the else clause).
> In this case, this indeed looks rather harsh.
This is indeed the case (unless the if is eliminated completely in the
if_conversion). 

> I would have said in theory somehow the break should be some op which
> (despite not having a dst) has side-effects so it would not be
> subject to elimination somewhere (as there would be a if->next node
> in this case then).
It is the else that vanishes, but only if there is only a break in the
else path, if there there is also an ALU clause, then the else branch
is created propperly. 

> Albeit I'm completely oblivious how it really gets optimized away, is
> that based on liveness analysis or something? The sb code is a
> mystery to me...
I'm trying to understand it, but is is very dificult to grasp how it
works even with the debugging output. Well, maybe Dave has a better
idea. 

Best, 
Gert 

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


Re: [Mesa-dev] [PATCH shaderdb 2/3] run: fallback to 3.1 core context

2018-01-29 Thread Rob Clark
On Mon, Jan 29, 2018 at 2:39 PM, Ilia Mirkin  wrote:
> On Mon, Jan 29, 2018 at 2:26 PM, Rob Clark  wrote:
>> If we can't create a 3.2 core context, fall back to a 3.1 context.
>> ---
>>  run.c | 17 +++--
>>  1 file changed, 15 insertions(+), 2 deletions(-)
>>
>> diff --git a/run.c b/run.c
>> index 79d771e..2056ebd 100644
>> --- a/run.c
>> +++ b/run.c
>> @@ -383,9 +383,22 @@ create_context(EGLDisplay egl_dpy, EGLConfig cfg, enum 
>> shader_type type)
>>  EGL_NONE
>>  };
>>  switch (type) {
>> -case TYPE_CORE:
>> +case TYPE_CORE: {
>>  eglBindAPI(EGL_OPENGL_API);
>> -return eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
>> +EGLContext core_ctx =
>> +eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
>> +
>> +if (core_ctx == EGL_NO_CONTEXT) {
>> +static const EGLint attribs_31[] = {
>> +EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
>> +EGL_CONTEXT_MINOR_VERSION_KHR, 1,
>> +EGL_NONE
>> +};
>> +core_ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, 
>> attribs_31);
>
> Should ensure that this context does not expose GL_ARB_compatibility.
> Otherwise it's a compat-type context.
>

Hmm, does that mean there is no way to create a 3.1 core profile if a
driver supports 3.1 compat?

btw, I wonder how much we really care.. afaict all this core/compat
logic in shader-db runner must just be to avoid using a core context
for shaders asking for glsl version <= 130 (presumably in case they
use features removed from core).  So I guess it doesn't really matter
if we ended up with a 3.1 compat profile.

(Plus, I wonder what the odds of a driver supporting 3.1 compat but
not 3.2 core??)

BR,
-R

>> +}
>> +
>> +return core_ctx;
>> +}
>>  case TYPE_COMPAT:
>>  eglBindAPI(EGL_OPENGL_API);
>>  return eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, &attribs[6]);
>> --
>> 2.14.3
>>
>> ___
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 4/8] radeonsi/nir: add si_nir_load_sample_position() helper

2018-01-29 Thread Marek Olšák
It would be better to adjust the interface of load_sample_position as
needed instead of adding a new wrapper.

Marek

On Mon, Jan 15, 2018 at 4:46 AM, Timothy Arceri  wrote:
> ---
>  src/gallium/drivers/radeonsi/si_shader.c | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
> b/src/gallium/drivers/radeonsi/si_shader.c
> index 8e91a45455..a04b01eb79 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -1905,6 +1905,12 @@ static LLVMValueRef load_sample_position(struct 
> si_shader_context *ctx, LLVMValu
> return lp_build_gather_values(&ctx->gallivm, pos, 4);
>  }
>
> +static LLVMValueRef si_nir_load_sample_position(struct ac_shader_abi *abi, 
> LLVMValueRef sample_id)
> +{
> +   struct si_shader_context *ctx = si_shader_context_from_abi(abi);
> +   return load_sample_position(ctx, sample_id);
> +}
> +
>  static LLVMValueRef si_load_tess_coord(struct ac_shader_abi *abi,
>LLVMTypeRef type,
>unsigned num_components)
> --
> 2.14.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH shaderdb 2/3] run: fallback to 3.1 core context

2018-01-29 Thread Ilia Mirkin
On Mon, Jan 29, 2018 at 2:26 PM, Rob Clark  wrote:
> If we can't create a 3.2 core context, fall back to a 3.1 context.
> ---
>  run.c | 17 +++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/run.c b/run.c
> index 79d771e..2056ebd 100644
> --- a/run.c
> +++ b/run.c
> @@ -383,9 +383,22 @@ create_context(EGLDisplay egl_dpy, EGLConfig cfg, enum 
> shader_type type)
>  EGL_NONE
>  };
>  switch (type) {
> -case TYPE_CORE:
> +case TYPE_CORE: {
>  eglBindAPI(EGL_OPENGL_API);
> -return eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
> +EGLContext core_ctx =
> +eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
> +
> +if (core_ctx == EGL_NO_CONTEXT) {
> +static const EGLint attribs_31[] = {
> +EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
> +EGL_CONTEXT_MINOR_VERSION_KHR, 1,
> +EGL_NONE
> +};
> +core_ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, 
> attribs_31);

Should ensure that this context does not expose GL_ARB_compatibility.
Otherwise it's a compat-type context.

> +}
> +
> +return core_ctx;
> +}
>  case TYPE_COMPAT:
>  eglBindAPI(EGL_OPENGL_API);
>  return eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, &attribs[6]);
> --
> 2.14.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/8] radeonsi/nir: add si_nir_lookup_interp_param() helper

2018-01-29 Thread Marek Olšák
On Mon, Jan 15, 2018 at 4:46 AM, Timothy Arceri  wrote:
> ---
>  src/amd/common/ac_nir_to_llvm.c   |  4 ---
>  src/amd/common/ac_nir_to_llvm.h   |  5 
>  src/amd/common/ac_shader_abi.h|  2 ++
>  src/gallium/drivers/radeonsi/si_shader_internal.h |  4 +++
>  src/gallium/drivers/radeonsi/si_shader_nir.c  | 36 
> +++
>  5 files changed, 47 insertions(+), 4 deletions(-)
>
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index e79fdd2ec2..3efb01137c 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -3926,10 +3926,6 @@ static LLVMValueRef visit_var_atomic(struct 
> nir_to_llvm_context *ctx,
> return result;
>  }
>
> -#define INTERP_CENTER 0
> -#define INTERP_CENTROID 1
> -#define INTERP_SAMPLE 2
> -
>  static LLVMValueRef lookup_interp_param(struct nir_to_llvm_context *ctx,
> enum glsl_interp_mode interp, 
> unsigned location)
>  {
> diff --git a/src/amd/common/ac_nir_to_llvm.h b/src/amd/common/ac_nir_to_llvm.h
> index b3ad0a0985..99bc3ef8dd 100644
> --- a/src/amd/common/ac_nir_to_llvm.h
> +++ b/src/amd/common/ac_nir_to_llvm.h
> @@ -115,6 +115,11 @@ enum ac_ud_index {
> AC_UD_MAX_UD = AC_UD_TCS_MAX_UD,
>  };
>
> +/* Interpolation locations */
> +#define INTERP_CENTER 0
> +#define INTERP_CENTROID 1
> +#define INTERP_SAMPLE 2

This should probably be in a different patch.

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


[Mesa-dev] [Bug 104843] Mesa version not updated for rebuild

2018-01-29 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=104843

Bug ID: 104843
   Summary: Mesa version not updated for rebuild
   Product: Mesa
   Version: git
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Other
  Assignee: baker.dyla...@gmail.com
  Reporter: mark.a.ja...@intel.com
QA Contact: mesa-dev@lists.freedesktop.org

I rebuilt mesa 18.0rc3, but was surprised to get the following result:

$ glxinfo | grep "OpenGL version string"
OpenGL version string: 3.0 Mesa 18.0.0-rc2 (git-17c0e248d7)

The git sha is correct, but the rc2 string did not get updated.

This may create confusion when developers report bugs and use glxinfo to report
the version of mesa they are testing.

Apparently, VERSION is only reevaluated when the meson build is reconfigured. 
This should be fixed in the build if possible.  It may be that this is a Meson
limitation; if so, we need a Meson feature request logged in github, or another
mechanism within Mesa for version handling.

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


Re: [Mesa-dev] [PATCH] r600/sb: Force ELSE path if the byte code started off with it

2018-01-29 Thread Roland Scheidegger
Am 29.01.2018 um 13:15 schrieb Gert Wollny:
> sb optimized away the ELSE in a construct like
> 
>while (foo) {
>   if (bar ) {
>  do something;
>   } else {
>  break;
>   }
>}
> 
> resulting in
> 
>while (foo) {
>   if (bar ) {
>  do something;
>  break;
>   }
>}
> 
> which is obviously wrong.
> 
> With this patch an ELSE is inserted also if there was one before optimization.
> This fixes piglit shaders@ssa@fs-if-def-else-break.
> 
> It might introduce a penalty by keeping an ELSE instruction when it can
> actually be really optimized away though.

Am I correct assuming that for something like
   while (foo) {
  if (bar) {
 do something;
  } else {
 /* nothing */
  }
   }
The else clause wouldn't get optimized away neither?
(This of course is a trivial example, but I suppose it would extend to
cases where the optimizer actually optimized away the alu instructions
in the else clause).
In this case, this indeed looks rather harsh.
I would have said in theory somehow the break should be some op which
(despite not having a dst) has side-effects so it would not be subject
to elimination somewhere (as there would be a if->next node in this case
then).
Albeit I'm completely oblivious how it really gets optimized away, is
that based on liveness analysis or something? The sb code is a mystery
to me...

Roland


> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101442
> ---
> I think there should be a better way to ensure that the else is inserted 
> in this case, but so far it elluded me. 
> 
> I have no mesa-git write access. 
> 
>  src/gallium/drivers/r600/sb/sb_bc_finalize.cpp | 4 +---
>  src/gallium/drivers/r600/sb/sb_bc_parser.cpp   | 5 -
>  src/gallium/drivers/r600/sb/sb_ir.h| 3 ++-
>  3 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp 
> b/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
> index 099b295f18..4450247caf 100644
> --- a/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
> +++ b/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
> @@ -208,9 +208,7 @@ void bc_finalizer::finalize_if(region_node* r) {
>   r->push_front(if_jump);
>   r->push_back(if_pop);
>  
> - bool has_else = n_if->next;
> -
> - if (has_else) {
> + if (n_if->has_else || n_if->next) {
>   cf_node *nelse = sh.create_cf(CF_OP_ELSE);
>   n_if->insert_after(nelse);
>   if_jump->jump(nelse);
> diff --git a/src/gallium/drivers/r600/sb/sb_bc_parser.cpp 
> b/src/gallium/drivers/r600/sb/sb_bc_parser.cpp
> index 970e4141d5..f37067b8e2 100644
> --- a/src/gallium/drivers/r600/sb/sb_bc_parser.cpp
> +++ b/src/gallium/drivers/r600/sb/sb_bc_parser.cpp
> @@ -959,8 +959,11 @@ int bc_parser::prepare_if(cf_node* c) {
>  
>   c->insert_before(reg);
>  
> - if (c_else != end)
> + if (c_else != end) {
> + n_if->has_else = true; 
>   dep->move(c_else, end);
> + }
> +
>   dep2->move(c, end);
>  
>   reg->push_back(dep);
> diff --git a/src/gallium/drivers/r600/sb/sb_ir.h 
> b/src/gallium/drivers/r600/sb/sb_ir.h
> index bee947504e..af9b161597 100644
> --- a/src/gallium/drivers/r600/sb/sb_ir.h
> +++ b/src/gallium/drivers/r600/sb/sb_ir.h
> @@ -1091,12 +1091,13 @@ public:
>  
>  class if_node : public container_node {
>  protected:
> - if_node() : container_node(NT_IF, NST_LIST), cond() {};
> + if_node() : container_node(NT_IF, NST_LIST), cond(), has_else(false) {};
>  public:
>   value *cond; // glued to pseudo output (dst[2]) of the PRED_SETxxx
>  
>   virtual bool accept(vpass &p, bool enter);
>  
> + bool has_else;
>   friend class shader;
>  };
>  
> 

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


[Mesa-dev] [PATCH shaderdb 1/3] run: split out helper to create contexts

2018-01-29 Thread Rob Clark
Since we need to create contexts on both the main thread and omp
threads, combine things into a single helper.  This reduces some
duplication of logic in the following patches.
---
 run.c | 72 ++-
 1 file changed, 50 insertions(+), 22 deletions(-)

diff --git a/run.c b/run.c
index 69fe23d..79d771e 100644
--- a/run.c
+++ b/run.c
@@ -57,6 +57,7 @@ struct context_info {
 };
 
 enum shader_type {
+TYPE_NONE,
 TYPE_CORE,
 TYPE_COMPAT,
 TYPE_VP,
@@ -367,6 +368,32 @@ get_glsl_version(void)
 return major * 100 + minor;
 }
 
+static EGLContext
+create_context(EGLDisplay egl_dpy, EGLConfig cfg, enum shader_type type)
+{
+static const EGLint attribs[] = {
+EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR,
+EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
+EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
+EGL_CONTEXT_MINOR_VERSION_KHR, 2,
+EGL_NONE
+};
+static const EGLint es_attribs[] = {
+EGL_CONTEXT_CLIENT_VERSION, 2,
+EGL_NONE
+};
+switch (type) {
+case TYPE_CORE:
+eglBindAPI(EGL_OPENGL_API);
+return eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
+case TYPE_COMPAT:
+eglBindAPI(EGL_OPENGL_API);
+return eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, &attribs[6]);
+default:
+return NULL;
+}
+}
+
 int
 main(int argc, char **argv)
 {
@@ -507,19 +534,11 @@ main(int argc, char **argv)
 ret = -1;
 goto egl_terminate;
 }
-eglBindAPI(EGL_OPENGL_API);
 
 static struct context_info core = { 0 }, compat = { 0 };
 
-static const EGLint attribs[] = {
-EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR,
-EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
-EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
-EGL_CONTEXT_MINOR_VERSION_KHR, 2,
-EGL_NONE
-};
-EGLContext core_ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT,
-   attribs);
+EGLContext core_ctx = create_context(egl_dpy, cfg, TYPE_CORE);
+
 if (core_ctx != EGL_NO_CONTEXT &&
 eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, core_ctx)) {
 int num_extensions;
@@ -566,8 +585,7 @@ main(int argc, char **argv)
 }
 }
 
-EGLContext compat_ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT,
- &attribs[6]);
+EGLContext compat_ctx = create_context(egl_dpy, cfg, TYPE_COMPAT);
 if (compat_ctx == EGL_NO_CONTEXT) {
 fprintf(stderr, "ERROR: eglCreateContext() failed\n");
 ret = -1;
@@ -611,10 +629,7 @@ main(int argc, char **argv)
 struct timespec start, end;
 clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
 
-eglBindAPI(EGL_OPENGL_API);
-
-EGLContext core_ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT,
-   attribs);
+EGLContext core_ctx = create_context(egl_dpy, cfg, TYPE_CORE);
 if (core_ctx != EGL_NO_CONTEXT &&
 eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, core_ctx)) 
{
 glEnable(GL_DEBUG_OUTPUT);
@@ -628,14 +643,13 @@ main(int argc, char **argv)
 glDebugMessageCallback(callback, ¤t_shader_name);
 }
 
-EGLContext compat_ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT,
- &attribs[6]);
+EGLContext compat_ctx = create_context(egl_dpy, cfg, TYPE_COMPAT);
 if (compat_ctx == EGL_NO_CONTEXT) {
 fprintf(stderr, "ERROR: eglCreateContext() failed\n");
 exit(-1);
 }
 
-bool ctx_is_core = false;
+enum shader_type current_type = TYPE_NONE;
 if (!eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE,
 compat_ctx)) {
 fprintf(stderr, "ERROR: eglMakeCurrent() failed\n");
@@ -685,15 +699,29 @@ main(int argc, char **argv)
 continue;
 }
 
-if (ctx_is_core != (type == TYPE_CORE)) {
+if (current_type != type) {
+EGLContext ctx;
+
 ctx_switches++;
+
+switch (type) {
+case TYPE_CORE:
+eglBindAPI(EGL_OPENGL_API);
+ctx = core_ctx;
+break;
+default:
+eglBindAPI(EGL_OPENGL_API);
+ctx = compat_ctx;
+break;
+}
+
 if (!eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE,
-type == TYPE_CORE ? core_ctx : 
compat_ctx)) {
+ctx)) {
 fprintf(stderr, "ERROR: eglMakeCurrent() failed\n");
 continue;
 }
 }
-ctx_is_core = type == TYPE_CORE;
+current_type = type;
 
 /* If the

[Mesa-dev] [PATCH shaderdb 3/3] run: add GLES support

2018-01-29 Thread Rob Clark
---
 run.c | 63 ---
 1 file changed, 60 insertions(+), 3 deletions(-)

diff --git a/run.c b/run.c
index 2056ebd..23d2b07 100644
--- a/run.c
+++ b/run.c
@@ -60,6 +60,7 @@ enum shader_type {
 TYPE_NONE,
 TYPE_CORE,
 TYPE_COMPAT,
+TYPE_ES,
 TYPE_VP,
 TYPE_FP,
 };
@@ -101,6 +102,7 @@ extension_in_string(const char *haystack, const char 
*needle)
 
 static struct shader *
 get_shaders(const struct context_info *core, const struct context_info *compat,
+const struct context_info *es,
 const char *text, size_t text_size,
 enum shader_type *type, unsigned *num_shaders,
 bool *use_separate_shader_objects,
@@ -109,6 +111,7 @@ get_shaders(const struct context_info *core, const struct 
context_info *compat,
 static const char *req = "[require]";
 static const char *gl_req = "\nGL >= ";
 static const char *glsl_req = "\nGLSL >= ";
+static const char *glsl_es_req = "\nGLSL ES >= ";
 static const char *fp_req = "\nGL_ARB_fragment_program";
 static const char *vp_req = "\nGL_ARB_vertex_program";
 static const char *sso_req = "\nSSO ENABLED";
@@ -154,6 +157,18 @@ get_shaders(const struct context_info *core, const struct 
context_info *compat,
 }
 *type = TYPE_CORE;
 }
+} else if (memcmp(text, glsl_es_req, strlen(glsl_es_req)) == 0) {
+text += strlen(glsl_es_req);
+long major = strtol(text, (char **)&text, 10);
+long minor = strtol(text + 1, (char **)&text, 10);
+long version = major * 100 + minor;
+
+if (unlikely(version > es->max_glsl_version)) {
+fprintf(stderr, "SKIP: %s requires GLSL ES %ld\n",
+shader_name, version);
+return NULL;
+}
+*type = TYPE_ES;
 } else if (memcmp(text, fp_req, strlen(fp_req)) == 0) {
 *type = TYPE_FP;
 } else if (memcmp(text, vp_req, strlen(vp_req)) == 0) {
@@ -361,9 +376,13 @@ static void addenv(const char *name, const char *value)
 static int
 get_glsl_version(void)
 {
+const char *es_prefix = "OpenGL ES GLSL ES ";
 const char *ver = glGetString(GL_SHADING_LANGUAGE_VERSION);
 unsigned major = 0, minor = 0;
 
+if (strstr(ver, es_prefix) == ver)
+ver += strlen(es_prefix);
+
 sscanf(ver, "%u.%u", &major, &minor);
 return major * 100 + minor;
 }
@@ -402,6 +421,9 @@ create_context(EGLDisplay egl_dpy, EGLConfig cfg, enum 
shader_type type)
 case TYPE_COMPAT:
 eglBindAPI(EGL_OPENGL_API);
 return eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, &attribs[6]);
+case TYPE_ES:
+eglBindAPI(EGL_OPENGL_ES_API);
+return eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, es_attribs);
 default:
 return NULL;
 }
@@ -548,7 +570,23 @@ main(int argc, char **argv)
 goto egl_terminate;
 }
 
-static struct context_info core = { 0 }, compat = { 0 };
+static struct context_info core = { 0 }, compat = { 0 }, es = { 0 };
+
+EGLContext es_ctx = create_context(egl_dpy, cfg, TYPE_ES);
+if (es_ctx != EGL_NO_CONTEXT &&
+eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, es_ctx)) {
+
+es.extension_string = (char *)glGetString(GL_EXTENSIONS);
+es.extension_string_len = strlen(es.extension_string);
+
+es.max_glsl_version = get_glsl_version();
+
+if (!extension_in_string(es.extension_string, "GL_KHR_debug")) {
+fprintf(stderr, "ERROR: Missing GL_KHR_debug\n");
+ret = -1;
+goto egl_terminate;
+}
+}
 
 EGLContext core_ctx = create_context(egl_dpy, cfg, TYPE_CORE);
 
@@ -642,6 +680,20 @@ main(int argc, char **argv)
 struct timespec start, end;
 clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
 
+EGLContext es_ctx = create_context(egl_dpy, cfg, TYPE_ES);
+if (es_ctx != EGL_NO_CONTEXT &&
+eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, es_ctx)) {
+glEnable(GL_DEBUG_OUTPUT);
+glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
+glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE,
+  0, NULL, GL_FALSE);
+glDebugMessageControl(GL_DEBUG_SOURCE_SHADER_COMPILER,
+  GL_DEBUG_TYPE_OTHER,
+  GL_DEBUG_SEVERITY_NOTIFICATION, 0, NULL,
+  GL_TRUE);
+glDebugMessageCallback(callback, ¤t_shader_name);
+}
+
 EGLContext core_ctx = create_context(egl_dpy, cfg, TYPE_CORE);
 if (core_ctx != EGL_NO_CONTEXT &&
 eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, core_ctx)) 
{
@@ -703,7 +755,7 @@ main(int argc, char **argv)
 enum shader_type type;
 unsigned num_shaders;
 bool use_separate_shader_objects;
-struct shader *shader = g

[Mesa-dev] [PATCH shaderdb 2/3] run: fallback to 3.1 core context

2018-01-29 Thread Rob Clark
If we can't create a 3.2 core context, fall back to a 3.1 context.
---
 run.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/run.c b/run.c
index 79d771e..2056ebd 100644
--- a/run.c
+++ b/run.c
@@ -383,9 +383,22 @@ create_context(EGLDisplay egl_dpy, EGLConfig cfg, enum 
shader_type type)
 EGL_NONE
 };
 switch (type) {
-case TYPE_CORE:
+case TYPE_CORE: {
 eglBindAPI(EGL_OPENGL_API);
-return eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
+EGLContext core_ctx =
+eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
+
+if (core_ctx == EGL_NO_CONTEXT) {
+static const EGLint attribs_31[] = {
+EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
+EGL_CONTEXT_MINOR_VERSION_KHR, 1,
+EGL_NONE
+};
+core_ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, 
attribs_31);
+}
+
+return core_ctx;
+}
 case TYPE_COMPAT:
 eglBindAPI(EGL_OPENGL_API);
 return eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, &attribs[6]);
-- 
2.14.3

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


Re: [Mesa-dev] [PATCH 1/8] radeonsi/nir: add interpolate at intrinsics to scan_instruction()

2018-01-29 Thread Marek Olšák
The case statements should set these variables instead:

   boolean uses_persp_opcode_interp_centroid;
   boolean uses_persp_opcode_interp_offset;
   boolean uses_persp_opcode_interp_sample;
   boolean uses_linear_opcode_interp_centroid;
   boolean uses_linear_opcode_interp_offset;
   boolean uses_linear_opcode_interp_sample;

Marek

On Mon, Jan 15, 2018 at 4:46 AM, Timothy Arceri  wrote:
> ---
>  src/gallium/drivers/radeonsi/si_shader_nir.c | 26 ++
>  1 file changed, 26 insertions(+)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c 
> b/src/gallium/drivers/radeonsi/si_shader_nir.c
> index 20b3beccc4..fcc857f838 100644
> --- a/src/gallium/drivers/radeonsi/si_shader_nir.c
> +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
> @@ -124,6 +124,32 @@ static void scan_instruction(struct tgsi_shader_info 
> *info,
> case nir_intrinsic_ssbo_atomic_comp_swap:
> info->writes_memory = true;
> break;
> +   case nir_intrinsic_interp_var_at_centroid:
> +   case nir_intrinsic_interp_var_at_sample:
> +   case nir_intrinsic_interp_var_at_offset: {
> +   enum glsl_interp_mode interp =
> +   intr->variables[0]->var->data.interpolation;
> +   switch (interp) {
> +   case INTERP_MODE_SMOOTH:
> +   case INTERP_MODE_NONE:
> +   if (intr->intrinsic == 
> nir_intrinsic_interp_var_at_centroid)
> +   info->uses_persp_centroid = true;
> +   else
> +   info->uses_persp_center = true;
> +   break;
> +   case INTERP_MODE_NOPERSPECTIVE:
> +   if (intr->intrinsic == 
> nir_intrinsic_interp_var_at_centroid)
> +   info->uses_linear_centroid = true;
> +   else
> +   info->uses_linear_center = true;
> +   break;
> +   case INTERP_MODE_FLAT:
> +   break;
> +   default:
> +   unreachable("Unsupported interpoation type");
> +   }
> +   break;
> +   }
> default:
> break;
> }
> --
> 2.14.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] swr: don't export swr_create_screen_internal

2018-01-29 Thread Kyriazis, George
Yep, tested on our side, and looks good.

Reviewed-By: George Kyriazis 
mailto:george.kyria...@intel.com>>


On Jan 29, 2018, at 9:42 AM, Chuck Atkins 
mailto:chuck.atk...@kitware.com>> wrote:

Lgtm, should probably get a rb from Intel though to make sure it doesn't break 
anything they're trying to do.

Tested-by: Chuck Atkins 
mailto:chuck.atk...@kitware.com>>

On Jan 29, 2018 07:09, "Emil Velikov" 
mailto:emil.l.veli...@gmail.com>> wrote:
On 22 January 2018 at 17:52, Emil Velikov 
mailto:emil.l.veli...@gmail.com>> wrote:
> From: Emil Velikov 
> mailto:emil.veli...@collabora.com>>
>
> With earlier rework the user and provider of the symbol are within the
> same binary. Thus there's no point in exporting the function.
>
> Spotted while reviewing patch from Chuck, that nearly added another
> unneeded PUBLIC function.
>
> Cc: Chuck Atkins mailto:chuck.atk...@kitware.com>>
> Cc: Tim Rowley mailto:timothy.o.row...@intel.com>>
> Fixes: f50aa21456d "(swr: build driver proper separate from rasterizer")
> Signed-off-by: Emil Velikov 
> mailto:emil.veli...@collabora.com>>
> ---
> The comment might need updating as well, although I'm short on
> suggestions.
> ---
>  src/gallium/drivers/swr/swr_public.h   | 2 +-
>  src/gallium/drivers/swr/swr_screen.cpp | 1 -
>  2 files changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/swr/swr_public.h 
> b/src/gallium/drivers/swr/swr_public.h
> index 4b150705cd7..cb205479a91 100644
> --- a/src/gallium/drivers/swr/swr_public.h
> +++ b/src/gallium/drivers/swr/swr_public.h
> @@ -36,7 +36,7 @@ extern "C" {
>  struct pipe_screen *swr_create_screen(struct sw_winsys *winsys);
>
>  // arch-specific dll entry point
> -PUBLIC struct pipe_screen *swr_create_screen_internal(struct sw_winsys 
> *winsys);
> +struct pipe_screen *swr_create_screen_internal(struct sw_winsys *winsys);
>
>  #ifdef _WIN32
>  void swr_gdi_swap(struct pipe_screen *screen,
> diff --git a/src/gallium/drivers/swr/swr_screen.cpp 
> b/src/gallium/drivers/swr/swr_screen.cpp
> index b67ac25ac89..10b7e891aca 100644
> --- a/src/gallium/drivers/swr/swr_screen.cpp
> +++ b/src/gallium/drivers/swr/swr_screen.cpp
> @@ -1114,7 +1114,6 @@ swr_validate_env_options(struct swr_screen *screen)
>  }
>
>
> -PUBLIC
>  struct pipe_screen *
>  swr_create_screen_internal(struct sw_winsys *winsys)
>  {
> --
Humble ping?

-Eiml


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


Re: [Mesa-dev] [PATCH 00/20] Add support for GL_EXT_semaphore v3

2018-01-29 Thread Marek Olšák
On Tue, Jan 23, 2018 at 10:16 PM, Andres Rodriguez  wrote:
> Also, the associated piglit patches:
> https://lists.freedesktop.org/archives/piglit/2017-December/023600.html

You can just push the piglit patches if you get no review there.

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


Re: [Mesa-dev] [PATCH 12/20] mesa: implement buffer/texture barriers for semaphore signal/wait v2

2018-01-29 Thread Marek Olšák
On Mon, Jan 29, 2018 at 7:53 PM, Marek Olšák  wrote:
> On Tue, Jan 23, 2018 at 7:05 PM, Andres Rodriguez  wrote:
>> Make sure memory is accessible to the external client, for the specified
>> memory object, before the signal/after the wait.
>>
>> v2: fixed flush order with respect to wait/signal emission
>>
>> Signed-off-by: Andres Rodriguez 
>> ---
>>  src/mesa/main/dd.h  | 14 ++-
>>  src/mesa/main/externalobjects.c | 38 +++---
>>  src/mesa/state_tracker/st_cb_semaphoreobjects.c | 53 
>> +++--
>>  3 files changed, 95 insertions(+), 10 deletions(-)
>>
>> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
>> index abbc4d5f5c..b56dd176aa 100644
>> --- a/src/mesa/main/dd.h
>> +++ b/src/mesa/main/dd.h
>> @@ -1156,14 +1156,24 @@ struct dd_function_table {
>>  * server's command stream
>>  */
>> void (*ServerWaitSemaphoreObject)(struct gl_context *ctx,
>> - struct gl_semaphore_object *semObj);
>> + struct gl_semaphore_object *semObj,
>> + GLuint numBufferBarriers,
>> + struct gl_buffer_object **bufObjs,
>> + GLuint numTextureBarriers,
>> + struct gl_texture_object **texObjs,
>> + const GLenum *srcLayouts);
>>
>> /**
>>  * Introduce an operation to signal the semaphore object in the GL
>>  * server's command stream
>>  */
>> void (*ServerSignalSemaphoreObject)(struct gl_context *ctx,
>> -   struct gl_semaphore_object *semObj);
>> +   struct gl_semaphore_object *semObj,
>> +   GLuint numBufferBarriers,
>> +   struct gl_buffer_object **bufObjs,
>> +   GLuint numTextureBarriers,
>> +   struct gl_texture_object **texObjs,
>> +   const GLenum *dstLayouts);
>> /*@}*/
>>
>> /**
>> diff --git a/src/mesa/main/externalobjects.c 
>> b/src/mesa/main/externalobjects.c
>> index 4fb3ca07a9..c070d7a28d 100644
>> --- a/src/mesa/main/externalobjects.c
>> +++ b/src/mesa/main/externalobjects.c
>> @@ -23,6 +23,7 @@
>>
>>  #include "macros.h"
>>  #include "mtypes.h"
>> +#include "bufferobj.h"
>>  #include "context.h"
>>  #include "externalobjects.h"
>>  #include "teximage.h"
>> @@ -716,7 +717,8 @@ _mesa_WaitSemaphoreEXT(GLuint semaphore,
>>  {
>> GET_CURRENT_CONTEXT(ctx);
>> struct gl_semaphore_object *semObj;
>> -
>> +   struct gl_buffer_object **bufObjs;
>> +   struct gl_texture_object **texObjs;
>>
>> if (!ctx->Extensions.EXT_semaphore) {
>>_mesa_error(ctx, GL_INVALID_OPERATION, 
>> "glWaitSemaphoreEXT(unsupported)");
>> @@ -732,8 +734,20 @@ _mesa_WaitSemaphoreEXT(GLuint semaphore,
>> FLUSH_VERTICES( ctx, 0 );
>> FLUSH_CURRENT( ctx, 0 );
>>
>> -   /* TODO: memory barriers and layout transitions */
>> -   ctx->Driver.ServerWaitSemaphoreObject(ctx, semObj);
>> +   bufObjs = alloca(sizeof(struct gl_buffer_object **) * numBufferBarriers);
>> +   for (unsigned i = 0; i < numBufferBarriers; i++) {
>> +  bufObjs[i] = _mesa_lookup_bufferobj(ctx, buffers[i]);
>> +   }
>> +
>> +   texObjs = alloca(sizeof(struct gl_texture_object **) * 
>> numTextureBarriers);
>> +   for (unsigned i = 0; i < numTextureBarriers; i++) {
>> +  texObjs[i] = _mesa_lookup_texture(ctx, textures[i]);
>> +   }
>> +
>> +   ctx->Driver.ServerWaitSemaphoreObject(ctx, semObj,
>> + numBufferBarriers, bufObjs,
>> + numTextureBarriers, texObjs,
>> + srcLayouts);
>>  }
>>
>>  void GLAPIENTRY
>> @@ -746,6 +760,8 @@ _mesa_SignalSemaphoreEXT(GLuint semaphore,
>>  {
>> GET_CURRENT_CONTEXT(ctx);
>> struct gl_semaphore_object *semObj;
>> +   struct gl_buffer_object **bufObjs;
>> +   struct gl_texture_object **texObjs;
>>
>> if (!ctx->Extensions.EXT_semaphore) {
>>_mesa_error(ctx, GL_INVALID_OPERATION, 
>> "glSignalSemaphoreEXT(unsupported)");
>> @@ -761,8 +777,20 @@ _mesa_SignalSemaphoreEXT(GLuint semaphore,
>> FLUSH_VERTICES( ctx, 0 );
>> FLUSH_CURRENT( ctx, 0 );
>>
>> -   /* TODO: memory barriers and layout transitions */
>> -   ctx->Driver.ServerSignalSemaphoreObject(ctx, semObj);
>> +   bufObjs = alloca(sizeof(struct gl_buffer_object **) * numBufferBarriers);
>> +   for (unsigned i = 0; i < numBufferBarriers; i++) {
>> +  bufObjs[i] = _mesa_lookup_bufferobj(ctx, buffers[i]);
>> +   }
>> +
>> +   texObjs = alloca(sizeof(struct gl_texture_object **) * 
>> numTextureBarriers);
>> +   for (unsigned i = 0; i < numTextureBarriers; i++) {
>> +  texObjs[i] = _mesa_lookup_texture(ctx,

Re: [Mesa-dev] [PATCH 12/20] mesa: implement buffer/texture barriers for semaphore signal/wait v2

2018-01-29 Thread Marek Olšák
On Tue, Jan 23, 2018 at 7:05 PM, Andres Rodriguez  wrote:
> Make sure memory is accessible to the external client, for the specified
> memory object, before the signal/after the wait.
>
> v2: fixed flush order with respect to wait/signal emission
>
> Signed-off-by: Andres Rodriguez 
> ---
>  src/mesa/main/dd.h  | 14 ++-
>  src/mesa/main/externalobjects.c | 38 +++---
>  src/mesa/state_tracker/st_cb_semaphoreobjects.c | 53 
> +++--
>  3 files changed, 95 insertions(+), 10 deletions(-)
>
> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
> index abbc4d5f5c..b56dd176aa 100644
> --- a/src/mesa/main/dd.h
> +++ b/src/mesa/main/dd.h
> @@ -1156,14 +1156,24 @@ struct dd_function_table {
>  * server's command stream
>  */
> void (*ServerWaitSemaphoreObject)(struct gl_context *ctx,
> - struct gl_semaphore_object *semObj);
> + struct gl_semaphore_object *semObj,
> + GLuint numBufferBarriers,
> + struct gl_buffer_object **bufObjs,
> + GLuint numTextureBarriers,
> + struct gl_texture_object **texObjs,
> + const GLenum *srcLayouts);
>
> /**
>  * Introduce an operation to signal the semaphore object in the GL
>  * server's command stream
>  */
> void (*ServerSignalSemaphoreObject)(struct gl_context *ctx,
> -   struct gl_semaphore_object *semObj);
> +   struct gl_semaphore_object *semObj,
> +   GLuint numBufferBarriers,
> +   struct gl_buffer_object **bufObjs,
> +   GLuint numTextureBarriers,
> +   struct gl_texture_object **texObjs,
> +   const GLenum *dstLayouts);
> /*@}*/
>
> /**
> diff --git a/src/mesa/main/externalobjects.c b/src/mesa/main/externalobjects.c
> index 4fb3ca07a9..c070d7a28d 100644
> --- a/src/mesa/main/externalobjects.c
> +++ b/src/mesa/main/externalobjects.c
> @@ -23,6 +23,7 @@
>
>  #include "macros.h"
>  #include "mtypes.h"
> +#include "bufferobj.h"
>  #include "context.h"
>  #include "externalobjects.h"
>  #include "teximage.h"
> @@ -716,7 +717,8 @@ _mesa_WaitSemaphoreEXT(GLuint semaphore,
>  {
> GET_CURRENT_CONTEXT(ctx);
> struct gl_semaphore_object *semObj;
> -
> +   struct gl_buffer_object **bufObjs;
> +   struct gl_texture_object **texObjs;
>
> if (!ctx->Extensions.EXT_semaphore) {
>_mesa_error(ctx, GL_INVALID_OPERATION, 
> "glWaitSemaphoreEXT(unsupported)");
> @@ -732,8 +734,20 @@ _mesa_WaitSemaphoreEXT(GLuint semaphore,
> FLUSH_VERTICES( ctx, 0 );
> FLUSH_CURRENT( ctx, 0 );
>
> -   /* TODO: memory barriers and layout transitions */
> -   ctx->Driver.ServerWaitSemaphoreObject(ctx, semObj);
> +   bufObjs = alloca(sizeof(struct gl_buffer_object **) * numBufferBarriers);
> +   for (unsigned i = 0; i < numBufferBarriers; i++) {
> +  bufObjs[i] = _mesa_lookup_bufferobj(ctx, buffers[i]);
> +   }
> +
> +   texObjs = alloca(sizeof(struct gl_texture_object **) * 
> numTextureBarriers);
> +   for (unsigned i = 0; i < numTextureBarriers; i++) {
> +  texObjs[i] = _mesa_lookup_texture(ctx, textures[i]);
> +   }
> +
> +   ctx->Driver.ServerWaitSemaphoreObject(ctx, semObj,
> + numBufferBarriers, bufObjs,
> + numTextureBarriers, texObjs,
> + srcLayouts);
>  }
>
>  void GLAPIENTRY
> @@ -746,6 +760,8 @@ _mesa_SignalSemaphoreEXT(GLuint semaphore,
>  {
> GET_CURRENT_CONTEXT(ctx);
> struct gl_semaphore_object *semObj;
> +   struct gl_buffer_object **bufObjs;
> +   struct gl_texture_object **texObjs;
>
> if (!ctx->Extensions.EXT_semaphore) {
>_mesa_error(ctx, GL_INVALID_OPERATION, 
> "glSignalSemaphoreEXT(unsupported)");
> @@ -761,8 +777,20 @@ _mesa_SignalSemaphoreEXT(GLuint semaphore,
> FLUSH_VERTICES( ctx, 0 );
> FLUSH_CURRENT( ctx, 0 );
>
> -   /* TODO: memory barriers and layout transitions */
> -   ctx->Driver.ServerSignalSemaphoreObject(ctx, semObj);
> +   bufObjs = alloca(sizeof(struct gl_buffer_object **) * numBufferBarriers);
> +   for (unsigned i = 0; i < numBufferBarriers; i++) {
> +  bufObjs[i] = _mesa_lookup_bufferobj(ctx, buffers[i]);
> +   }
> +
> +   texObjs = alloca(sizeof(struct gl_texture_object **) * 
> numTextureBarriers);
> +   for (unsigned i = 0; i < numTextureBarriers; i++) {
> +  texObjs[i] = _mesa_lookup_texture(ctx, textures[i]);
> +   }
> +
> +   ctx->Driver.ServerSignalSemaphoreObject(ctx, semObj,
> +   numBufferBarriers, bufObjs,
> +

Re: [Mesa-dev] [PATCH 11/11] vbo: overhaul display list vertex array setup/binding code

2018-01-29 Thread Brian Paul

On 01/27/2018 08:01 AM, Mathias Fröhlich wrote:

Hi Brian,

That one will not work as is.

Display lists are shared objects across contexts.
Means past that change the

const struct gl_vertex_array *inputs[VBO_ATTRIB_MAX];

may be concurrently written to from different threads filling in current value
pointers from the context where the list is executed from. That leaves current
values form a differnet context and concurrency issues at least.


Ah right.  At one point I thought about dlist sharing, but I forgot to 
address that in the end.


I think one way to address that would be to put a mutex in the 
vbo_save_vertex_list so it can only be accessed by one context at a 
time.  Plus, check if the calling context matches to compile-time 
context - if they don't match, update the 'current values'.


I'll think about it more though.



Beside that I am also not sure if the array update logic in bind_vertex_list
works correctly when VBO_ATTRIB* arrays ending in an aliasing VERT_ATTRIB*
slot are both enabled. You probably need to currectly mask out the VBO_ATTRIB
arrays before you distribute them across the inputs[] array. But the the logic
just to store subsequent node->arrays entries to save memory fails when
skipping the masked out arrays.


Can you provide a concrete example of what you mean?

Thanks for reviewing!

-Brian




best

Mathias

On Thursday, 25 January 2018 00:20:35 CET Brian Paul wrote:

Do more of the vertex array setup at display list compilation time
via the compile_vertex_list() function.

Then, at draw time, just do final vertex array setup dependent on
whether we're using fixed function or a vertex shader.

This can help apps which use a lot of short display list drawing.
---
  src/mesa/vbo/vbo_save.h  |  11 ++-
  src/mesa/vbo/vbo_save_api.c  |  93 ++---
  src/mesa/vbo/vbo_save_draw.c | 157 +

+-

  3 files changed, 147 insertions(+), 114 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index 51ea9cc..62a9d54 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -85,6 +85,16 @@ struct vbo_save_vertex_list {
  
 struct vbo_save_vertex_store *vertex_store;

 struct vbo_save_primitive_store *prim_store;
+
+   /* Array [bitcount(enabled)] of gl_vertex_array objects describing
+* the vertex data contained in this vbo_save_vertex_list.
+*/
+   struct gl_vertex_array *arrays;
+
+   /* The arrays to actually use at draw time.  Some will point at the
+* 'arrays' field above.  The rest will point at the vbo->currval arrays
+*/
+   const struct gl_vertex_array *inputs[VBO_ATTRIB_MAX];
  };
  
  
@@ -140,7 +150,6 @@ struct vbo_save_context {

 GLvertexformat vtxfmt;
 GLvertexformat vtxfmt_noop;  /**< Used if out_of_memory is true */
 struct gl_vertex_array arrays[VBO_ATTRIB_MAX];
-   const struct gl_vertex_array *inputs[VBO_ATTRIB_MAX];
  
 GLbitfield64 enabled; /**< mask of enabled vbo arrays. */

 GLubyte attrsz[VBO_ATTRIB_MAX];  /**< 1, 2, 3 or 4 */
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 11c40a2..e394d88 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -412,8 +412,80 @@ convert_line_loop_to_strip(struct vbo_save_context

*save,
  
  
  /**

- * Insert the active immediate struct onto the display list currently
- * being built.
+ * Prepare the vertex arrays which will be used for drawing the primitives
+ * in the given vertex list.  By doing it here, we can avoid doing this
+ * work at display list execution/draw time.
+ */
+static void
+setup_vertex_arrays(struct gl_context *ctx,
+struct vbo_save_vertex_list *node)
+{
+   struct vbo_context *vbo = vbo_context(ctx);
+   unsigned buffer_offset = node->buffer_offset;
+   unsigned attr;
+   const unsigned num_arrays = _mesa_bitcount_64(node->enabled);
+   unsigned array_count;
+
+   if (aligned_vertex_buffer_offset(node)) {
+  /* The vertex size is an exact multiple of the buffer offset.
+   * This means that we can use zero-based vertex attribute pointers
+   * and specify the start of the primitive with the _mesa_prim::start
+   * field.  This results in issuing several draw calls with identical
+   * vertex attribute information.  This can result in fewer state
+   * changes in drivers.  In particular, the Gallium CSO module will
+   * filter out redundant vertex buffer changes.
+   */
+  buffer_offset = 0;
+   }
+
+   assert(!node->arrays);
+   node->arrays = calloc(num_arrays, sizeof(struct gl_vertex_array));
+   if (!node->arrays) {
+  _mesa_error(ctx, GL_OUT_OF_MEMORY,
+  "compiling vertex data into display list");
+  /* just turn off all arrays */
+  node->enabled = 0;
+  return;
+   }
+
+   array_count = 0;
+   for (attr = 0; attr < VBO_ATTRIB_MAX; attr++) {
+  if (node->attrsz[attr]) {
+ /* this vertex array points at act

Re: [Mesa-dev] [PATCH 11/20] mesa/st: add support for semaphore object signal/wait v3

2018-01-29 Thread Marek Olšák
On Tue, Jan 23, 2018 at 7:05 PM, Andres Rodriguez  wrote:
> Bits to implement ServerWaitSemaphoreObject/ServerSignalSemaphoreObject
>
> v2:
>   - corresponding changes for gallium fence->semaphore rename
>   - flushing moved to mesa/main
>
> v3: s/semaphore/fence for pipe objects
>
> Signed-off-by: Andres Rodriguez 
> ---
>  src/mesa/state_tracker/st_cb_semaphoreobjects.c | 27 
> +
>  1 file changed, 27 insertions(+)
>
> diff --git a/src/mesa/state_tracker/st_cb_semaphoreobjects.c 
> b/src/mesa/state_tracker/st_cb_semaphoreobjects.c
> index 25e3043c40..5510102635 100644
> --- a/src/mesa/state_tracker/st_cb_semaphoreobjects.c
> +++ b/src/mesa/state_tracker/st_cb_semaphoreobjects.c
> @@ -1,5 +1,7 @@
> +
>  #include "main/imports.h"
>  #include "main/mtypes.h"
> +#include "main/context.h"
>
>  #include "main/externalobjects.h"
>
> @@ -46,10 +48,35 @@ st_import_semaphoreobj_fd(struct gl_context *ctx,
>  #endif
>  }
>
> +static void
> +st_server_wait_semaphore(struct gl_context *ctx,
> + struct gl_semaphore_object *semObj)
> +{
> +   struct st_semaphore_object *st_obj = st_semaphore_object(semObj);
> +   struct st_context *st = st_context(ctx);
> +   struct pipe_context *pipe = st->pipe;
> +

st_flush_bitmap_cache(st); should be called here.

> +   pipe->fence_server_sync(pipe, st_obj->fence);
> +}
> +
> +static void
> +st_server_signal_semaphore(struct gl_context *ctx,
> +   struct gl_semaphore_object *semObj)
> +{
> +   struct st_semaphore_object *st_obj = st_semaphore_object(semObj);
> +   struct st_context *st = st_context(ctx);
> +   struct pipe_context *pipe = st->pipe;
> +

st_flush_bitmap_cache(st); should be called here.

> +   /**TODO FIXME */
> +   pipe->fence_server_signal(pipe, st_obj->fence);
> +}
> +

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


Re: [Mesa-dev] [PATCH 10/11] vbo: optimize loops in bind_vertex_list(), vbo_exec_bind_arrays()

2018-01-29 Thread Brian Paul

On 01/27/2018 08:01 AM, Mathias Fröhlich wrote:

Hi Brian,

The change should not change the current behavior.
Nevertheless the current behavior as well as past your change the code has a
corner case that will not work correctly.


Can you elaborate?



I do have a hand full of unpublished changes here that will fix that potential
problem and achieve something similar to what you are doing now with different
means. So, if you don't mind not applying that one I that saves me from
intrusively rebasing my series here.


Sounds good.

-Brian



best

Mathias

On Thursday, 25 January 2018 00:20:34 CET Brian Paul wrote:

Instead of looping over 32 attributes, just scan the enabled attrib bits.
This involves manipulating the 'enabled' attributes variable depending
on whether we're using legacy GL or a vertex shader.

We can remove the varying_inputs variable since it's the same as
the new 'enabled' bitfield.
---
  src/mesa/vbo/vbo_exec_draw.c | 37 -
  src/mesa/vbo/vbo_save_draw.c | 36 +++-
  2 files changed, 63 insertions(+), 10 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 5cea7fe..fcda235 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -174,9 +174,9 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
 struct vbo_context *vbo = vbo_context(ctx);
 struct vbo_exec_context *exec = &vbo->exec;
 struct gl_vertex_array *arrays = exec->vtx.arrays;
-   const GLubyte *map;
+   const GLubyte *map;  /** map from VERT_ATTRIB_x to VBO_ATTRIB_x */
 GLuint attr;
-   GLbitfield varying_inputs = 0x0;
+   GLbitfield64 enabled = exec->vtx.enabled;
 bool swap_pos = false;
  
 /* Install the default (ie Current) attributes first */

@@ -194,6 +194,10 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
  &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr];
}
map = vbo->map_vp_none;
+
+  /* shift material attrib flags into generic attribute positions */
+  enabled = (enabled & VBO_ATTRIBS_LEGACY)
+ | ((enabled & VBO_ATTRIBS_MATERIALS) >> VBO_MATERIAL_SHIFT);
break;
 case VP_SHADER:
for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
@@ -203,6 +207,9 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
}
map = vbo->map_vp_arb;
  
+  /* per-vertex materials are to be ignored when using a VS */

+  enabled &= ~VBO_ATTRIBS_MATERIALS;
+
/* check if VERT_ATTRIB_POS is not read but VERT_BIT_GENERIC0 is

read.

 * In that case we effectively need to route the data from
 * glVertexAttrib(0, val) calls to feed into the GENERIC0 input.
@@ -218,13 +225,34 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
   exec->vtx.attrtype[VERT_ATTRIB_GENERIC0] = exec->vtx.attrtype[0];
   exec->vtx.attrptr[VERT_ATTRIB_GENERIC0] = exec->vtx.attrptr[0];
   exec->vtx.attrsz[0] = 0;
+ enabled &= ~BITFIELD64_BIT(VBO_ATTRIB_POS);
+ enabled |= BITFIELD64_BIT(VBO_ATTRIB_GENERIC0);
}
break;
 default:
unreachable("Bad vertex program mode");
 }
  
-   for (attr = 0; attr < VERT_ATTRIB_MAX ; attr++) {

+#ifdef DEBUG
+   /* verify the enabled bitmask is consistent with attribute size info */
+   {
+  GLbitfield64 used = 0x0;
+  for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
+ const GLuint src = map[attr];
+ if (exec->vtx.attrsz[src]) {
+assert(enabled & VERT_BIT(attr));
+used |= VERT_BIT(attr);
+ } else {
+assert((enabled & VERT_BIT(attr)) == 0);
+ }
+  }
+  assert(used == enabled);
+   }
+#endif
+
+   GLbitfield64 enabled_scan = enabled;
+   while (enabled_scan) {
+  const int attr = u_bit_scan64(&enabled_scan);
const GLuint src = map[attr];
  
if (exec->vtx.attrsz[src]) {

@@ -258,7 +286,6 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
 &arrays[attr].BufferObj,
 exec->vtx.bufferobj);
  
- varying_inputs |= VERT_BIT(attr);

}
 }
  
@@ -272,7 +299,7 @@ vbo_exec_bind_arrays(struct gl_context *ctx)

exec->vtx.attrsz[VERT_ATTRIB_GENERIC0] = 0;
 }
  
-   _mesa_set_varying_vp_inputs(ctx, varying_inputs);

+   _mesa_set_varying_vp_inputs(ctx, enabled);
 ctx->NewDriverState |= ctx->DriverFlags.NewArray;
  }
  
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c

index c86efcb..5f5dcbe 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -138,11 +138,11 @@ bind_vertex_list(struct gl_context *ctx,
 struct vbo_save_context *save = &vbo->save;
 struct gl_vertex_array *arrays = save->arrays;
 GLuint buffer_offset = node->buffer_offset;
-   const GLubyte *map;
+   const GLubyte *map;  /** map from VERT_ATTRIB_x to VBO_ATTRIB_x */
 GLuint attr;
 GLubyte node_attrsz

[Mesa-dev] [PATCH mesa 2/2] meson: move dep_libdrm_intel with the other dep_libdrm_*

2018-01-29 Thread Eric Engestrom
Signed-off-by: Eric Engestrom 
---
 meson.build | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/meson.build b/meson.build
index 6d7a8e976ff6ad002d9a..b70c03637beb705f1f9f 100644
--- a/meson.build
+++ b/meson.build
@@ -211,11 +211,6 @@ if with_gallium_pl111 and not with_gallium_vc4
   error('pl111 driver requires vc4 driver')
 endif
 
-dep_libdrm_intel = []
-if with_dri_i915 or with_gallium_i915
-  dep_libdrm_intel = dependency('libdrm_intel', version : '>= 
@0@'.format(libdrm_intel_version))
-endif
-
 system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'dragonfly', 
'linux'].contains(host_machine.system())
 
 if host_machine.system() == 'darwin'
@@ -970,6 +965,10 @@ dep_libdrm_radeon = []
 dep_libdrm_nouveau = []
 dep_libdrm_etnaviv = []
 dep_libdrm_freedreno = []
+dep_libdrm_intel = []
+if with_dri_i915 or with_gallium_i915
+  dep_libdrm_intel = dependency('libdrm_intel', version : '>= 
@0@'.format(libdrm_intel_version))
+endif
 if with_amd_vk or with_gallium_radeonsi
   dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 
@0@'.format(libdrm_amdgpu_version))
 endif
-- 
Cheers,
  Eric

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


[Mesa-dev] [PATCH mesa 1/2] meson: centralise the libdrm versions information

2018-01-29 Thread Eric Engestrom
The big comment is taken from the equivalent block in configure.ac

Signed-off-by: Eric Engestrom 
---
 meson.build | 30 +
 src/gallium/targets/d3dadapter9/meson.build |  2 +-
 src/mesa/drivers/dri/meson.build|  2 +-
 3 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/meson.build b/meson.build
index 0a00798c2a5093ec803b..6d7a8e976ff6ad002d9a 100644
--- a/meson.build
+++ b/meson.build
@@ -41,6 +41,20 @@ pre_args = [
   
'-DPACKAGE_BUGREPORT="https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa";',
 ]
 
+# The idea is that libdrm is distributed as one cohesive package, even
+# though it is composed of multiple libraries. However some drivers
+# may have different version requirements than others. This list
+# codifies which drivers need which version of libdrm. Any libdrm
+# version dependencies in non-driver-specific code should be reflected
+# in the first entry.
+libdrm_version   = '2.4.75'
+libdrm_amdgpu_version= '2.4.89'
+libdrm_etnaviv_version   = '2.4.82'
+libdrm_freedreno_version = '2.4.82'
+libdrm_intel_version = '2.4.75'
+libdrm_nouveau_version   = '2.4.66'
+libdrm_radeon_version= '2.4.71'
+
 with_vulkan_icd_dir = get_option('vulkan-icd-dir')
 with_tests = get_option('build-tests')
 with_valgrind = get_option('valgrind')
@@ -199,7 +213,7 @@ endif
 
 dep_libdrm_intel = []
 if with_dri_i915 or with_gallium_i915
-  dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75')
+  dep_libdrm_intel = dependency('libdrm_intel', version : '>= 
@0@'.format(libdrm_intel_version))
 endif
 
 system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'dragonfly', 
'linux'].contains(host_machine.system())
@@ -922,7 +936,7 @@ else
 endif
 
 with_gallium_drisw_kms = false
-dep_libdrm = dependency('libdrm', version : '>= 2.4.75',
+dep_libdrm = dependency('libdrm', version : '>= @0@'.format(libdrm_version),
 required : with_dri2 or with_dri3)
 if dep_libdrm.found()
   pre_args += '-DHAVE_LIBDRM'
@@ -957,20 +971,20 @@ dep_libdrm_nouveau = []
 dep_libdrm_etnaviv = []
 dep_libdrm_freedreno = []
 if with_amd_vk or with_gallium_radeonsi
-  dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.89')
+  dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 
@0@'.format(libdrm_amdgpu_version))
 endif
 if (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or
 with_gallium_r300 or with_gallium_r600)
-  dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71')
+  dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 
@0@'.format(libdrm_radeon_version))
 endif
 if with_gallium_nouveau or with_dri_nouveau
-  dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 2.4.66')
+  dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 
@0@'.format(libdrm_nouveau_version))
 endif
 if with_gallium_etnaviv
-  dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82')
+  dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 
@0@'.format(libdrm_etnaviv_version))
 endif
 if with_gallium_freedreno
-  dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 2.4.89')
+  dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 
@0@'.format(libdrm_freedreno_version))
 endif
 
 llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
@@ -1201,7 +1215,7 @@ inc_include = include_directories('include')
 
 gl_priv_reqs = [
   'x11', 'xext', 'xdamage >= 1.1', 'xfixes', 'x11-xcb', 'xcb',
-  'xcb-glx >= 1.8.1', 'libdrm >= 2.4.75',
+  'xcb-glx >= 1.8.1', 'libdrm >= @0@'.format(libdrm_version),
 ]
 if dep_xxf86vm != [] and dep_xxf86vm.found()
   gl_priv_reqs += 'xxf86vm'
diff --git a/src/gallium/targets/d3dadapter9/meson.build 
b/src/gallium/targets/d3dadapter9/meson.build
index 5476e80e70cf9e2dba5a..ef8062beef06a5daaa52 100644
--- a/src/gallium/targets/d3dadapter9/meson.build
+++ b/src/gallium/targets/d3dadapter9/meson.build
@@ -78,5 +78,5 @@ pkg.generate(
   name : 'd3d',
   description : 'Native D3D driver modules',
   version : '.'.join(nine_version),
-  requires_private : 'libdrm >= 2.4.75',
+  requires_private : 'libdrm >= @0@'.format(libdrm_version),
 )
diff --git a/src/mesa/drivers/dri/meson.build b/src/mesa/drivers/dri/meson.build
index 94798b0f5dadccb651ab..519639e8a4ec1d08b8f2 100644
--- a/src/mesa/drivers/dri/meson.build
+++ b/src/mesa/drivers/dri/meson.build
@@ -73,6 +73,6 @@ if with_dri
 description : 'Direct Rendering Infrastructure',
 version : meson.project_version(),
 variables : ['dridriverdir=${prefix}/' + dri_drivers_path],
-requires_private : ['libdrm >= 2.4.75'],  # FIXME: don't hardcode this
+requires_private : ['libdrm >= @0@'.format(libdrm_version)],
   )
 endif
-- 
Cheers,
  Eric

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


Re: [Mesa-dev] [PATCH] mesa: replace GLenum with GLenum16 in common structures (v4)

2018-01-29 Thread Marek Olšák
Looks good to me.

Marek

On Mon, Jan 29, 2018 at 6:54 PM, Brian Paul  wrote:
> From: Marek Olšák 
>
> v2: - fix glGet*
> - also use GLenum16 for DrawBuffers
> v3: - rebase to top of tree (BrianP) and incorporate Ian's suggestions
> v4: - fix a GLenum16 bug in VBO/save code, add some STATIC_ASSERT()s
>
> gl_context = 152432 -> 136840 bytes
> vbo_context = 22096 -> 20608 bytes
>
> Reviewed-by: Brian Paul 
> Reviewed-by: Nicolai Hähnle 
> ---
>  src/mesa/drivers/common/meta.h |   2 +-
>  src/mesa/drivers/dri/nouveau/nv04_state_frag.c |   4 +-
>  src/mesa/drivers/dri/nouveau/nv10_state_frag.c |   4 +-
>  src/mesa/main/attrib.c |  13 +-
>  src/mesa/main/buffers.c|  12 +-
>  src/mesa/main/buffers.h|   2 +-
>  src/mesa/main/context.c|   2 +-
>  src/mesa/main/get.c|  38 +
>  src/mesa/main/get_hash_params.py   | 152 +-
>  src/mesa/main/glheader.h   |   1 +
>  src/mesa/main/mtypes.h | 204 
> -
>  src/mesa/vbo/vbo_exec.h|   2 +-
>  src/mesa/vbo/vbo_save.h|   4 +-
>  src/mesa/vbo/vbo_save_api.c|   2 +
>  src/mesa/vbo/vbo_save_draw.c   |   4 +-
>  15 files changed, 250 insertions(+), 196 deletions(-)
>
> diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
> index 6d51854..3d9c291 100644
> --- a/src/mesa/drivers/common/meta.h
> +++ b/src/mesa/drivers/common/meta.h
> @@ -190,7 +190,7 @@ struct save_state
> struct gl_framebuffer *ReadBuffer;
>
> /** MESA_META_DRAW_BUFFERS */
> -   GLenum ColorDrawBuffers[MAX_DRAW_BUFFERS];
> +   GLenum16 ColorDrawBuffers[MAX_DRAW_BUFFERS];
>  };
>
>  /**
> diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c 
> b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
> index 248a7d2..bfe8eae 100644
> --- a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
> +++ b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
> @@ -49,8 +49,8 @@ struct combiner_state {
>
> /* GL state */
> GLenum mode;
> -   GLenum *source;
> -   GLenum *operand;
> +   GLenum16 *source;
> +   GLenum16 *operand;
> GLuint logscale;
>
> /* Derived HW state */
> diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_frag.c 
> b/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
> index c6e4bb0..42dff08 100644
> --- a/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
> +++ b/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
> @@ -67,8 +67,8 @@ struct combiner_state {
>
> /* GL state */
> GLenum mode;
> -   GLenum *source;
> -   GLenum *operand;
> +   GLenum16 *source;
> +   GLenum16 *operand;
> GLuint logscale;
>
> /* Derived HW state */
> diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
> index 50b65c4..3c12fd6 100644
> --- a/src/mesa/main/attrib.c
> +++ b/src/mesa/main/attrib.c
> @@ -1005,11 +1005,16 @@ _mesa_PopAttrib(void)
> * user FBO bound, GL_FRONT will be illegal and we'll need
> * to record that error.  Per OpenGL ARB decision.
> */
> -  if (multipleBuffers)
> - _mesa_DrawBuffers(ctx->Const.MaxDrawBuffers,
> -  color->DrawBuffer);
> -  else
> +  if (multipleBuffers) {
> + GLenum buffers[MAX_DRAW_BUFFERS];
> +
> + for (unsigned i = 0; i < ctx->Const.MaxDrawBuffers; i++)
> +buffers[i] = color->DrawBuffer[i];
> +
> + _mesa_DrawBuffers(ctx->Const.MaxDrawBuffers, buffers);
> +  } else {
>   _mesa_DrawBuffer(color->DrawBuffer[0]);
> +  }
> }
> _mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled);
> _mesa_AlphaFunc(color->AlphaFunc, color->AlphaRefUnclamped);
> diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
> index d364047..5492227 100644
> --- a/src/mesa/main/buffers.c
> +++ b/src/mesa/main/buffers.c
> @@ -299,7 +299,8 @@ draw_buffer(struct gl_context *ctx, struct gl_framebuffer 
> *fb,
> }
>
> /* if we get here, there's no error so set new state */
> -   _mesa_drawbuffers(ctx, fb, 1, &buffer, &destMask);
> +   const GLenum16 buffer16 = buffer;
> +   _mesa_drawbuffers(ctx, fb, 1, &buffer16, &destMask);
>
> /* Call device driver function only if fb is the bound draw buffer */
> if (fb == ctx->DrawBuffer) {
> @@ -573,7 +574,11 @@ draw_buffers(struct gl_context *ctx, struct 
> gl_framebuffer *fb, GLsizei n,
> }
>
> /* OK, if we get here, there were no errors so set the new state */
> -   _mesa_drawbuffers(ctx, fb, n, buffers, destMask);
> +   GLenum16 buffers16[MAX_DRAW_BUFFERS];
> +   for (i

Re: [Mesa-dev] [PATCH 08/20] mesa/st: add support for semaphore object create/import/delete v2

2018-01-29 Thread Marek Olšák
The new files are missing the license.

Marek

On Tue, Jan 23, 2018 at 7:04 PM, Andres Rodriguez  wrote:
> Add basic semaphore object operations.
>
> v2: s/semaphore/fence for pipe objects
>
> Signed-off-by: Andres Rodriguez 
> ---
>  src/mesa/Makefile.sources   |  2 +
>  src/mesa/meson.build|  2 +
>  src/mesa/state_tracker/st_cb_semaphoreobjects.c | 55 
> +
>  src/mesa/state_tracker/st_cb_semaphoreobjects.h | 25 +++
>  src/mesa/state_tracker/st_context.c |  2 +
>  5 files changed, 86 insertions(+)
>  create mode 100644 src/mesa/state_tracker/st_cb_semaphoreobjects.c
>  create mode 100644 src/mesa/state_tracker/st_cb_semaphoreobjects.h
>
> diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
> index 53fa486364..2e89da4133 100644
> --- a/src/mesa/Makefile.sources
> +++ b/src/mesa/Makefile.sources
> @@ -485,6 +485,8 @@ STATETRACKER_FILES = \
> state_tracker/st_cb_rasterpos.h \
> state_tracker/st_cb_readpixels.c \
> state_tracker/st_cb_readpixels.h \
> +   state_tracker/st_cb_semaphoreobjects.c \
> +   state_tracker/st_cb_semaphoreobjects.h \
> state_tracker/st_cb_strings.c \
> state_tracker/st_cb_strings.h \
> state_tracker/st_cb_syncobj.c \
> diff --git a/src/mesa/meson.build b/src/mesa/meson.build
> index 998953d641..d10747fdb1 100644
> --- a/src/mesa/meson.build
> +++ b/src/mesa/meson.build
> @@ -536,6 +536,8 @@ files_libmesa_gallium = files(
>'state_tracker/st_cb_readpixels.h',
>'state_tracker/st_cb_strings.c',
>'state_tracker/st_cb_strings.h',
> +  'state_tracker/st_cb_semaphoreobjects.c',
> +  'state_tracker/st_cb_semaphoreobjects.h',
>'state_tracker/st_cb_syncobj.c',
>'state_tracker/st_cb_syncobj.h',
>'state_tracker/st_cb_texturebarrier.c',
> diff --git a/src/mesa/state_tracker/st_cb_semaphoreobjects.c 
> b/src/mesa/state_tracker/st_cb_semaphoreobjects.c
> new file mode 100644
> index 00..25e3043c40
> --- /dev/null
> +++ b/src/mesa/state_tracker/st_cb_semaphoreobjects.c
> @@ -0,0 +1,55 @@
> +#include "main/imports.h"
> +#include "main/mtypes.h"
> +
> +#include "main/externalobjects.h"
> +
> +#include "st_context.h"
> +#include "st_cb_semaphoreobjects.h"
> +
> +#include "state_tracker/drm_driver.h"
> +#include "pipe/p_context.h"
> +#include "pipe/p_screen.h"
> +
> +static struct gl_semaphore_object *
> +st_semaphoreobj_alloc(struct gl_context *ctx, GLuint name)
> +{
> +   struct st_semaphore_object *st_obj = 
> ST_CALLOC_STRUCT(st_semaphore_object);
> +   if (!st_obj)
> +  return NULL;
> +
> +   _mesa_initialize_semaphore_object(ctx, &st_obj->Base, name);
> +   return &st_obj->Base;
> +}
> +
> +static void
> +st_semaphoreobj_free(struct gl_context *ctx,
> + struct gl_semaphore_object *semObj)
> +{
> +   _mesa_delete_semaphore_object(ctx, semObj);
> +}
> +
> +
> +static void
> +st_import_semaphoreobj_fd(struct gl_context *ctx,
> +   struct gl_semaphore_object *semObj,
> +   int fd)
> +{
> +   struct st_semaphore_object *st_obj = st_semaphore_object(semObj);
> +   struct st_context *st = st_context(ctx);
> +   struct pipe_context *pipe = st->pipe;
> +
> +   pipe->create_fence_fd(pipe, &st_obj->fence, fd, PIPE_FD_TYPE_SYNCOBJ);
> +
> +#if !defined(_WIN32)
> +   /* We own fd, but we no longer need it. So get rid of it */
> +   close(fd);
> +#endif
> +}
> +
> +void
> +st_init_semaphoreobject_functions(struct dd_function_table *functions)
> +{
> +   functions->NewSemaphoreObject = st_semaphoreobj_alloc;
> +   functions->DeleteSemaphoreObject = st_semaphoreobj_free;
> +   functions->ImportSemaphoreFd = st_import_semaphoreobj_fd;
> +}
> diff --git a/src/mesa/state_tracker/st_cb_semaphoreobjects.h 
> b/src/mesa/state_tracker/st_cb_semaphoreobjects.h
> new file mode 100644
> index 00..5004c607bf
> --- /dev/null
> +++ b/src/mesa/state_tracker/st_cb_semaphoreobjects.h
> @@ -0,0 +1,25 @@
> +#ifndef ST_CB_SEMAPHOREOBJECTS_H
> +#define ST_CB_SEMAPHOREOBJECTS_H
> +
> +#include "main/compiler.h"
> +#include "main/mtypes.h"
> +
> +struct dd_function_table;
> +struct pipe_screen;
> +
> +struct st_semaphore_object
> +{
> +   struct gl_semaphore_object Base;
> +   struct pipe_fence_handle *fence;
> +};
> +
> +static inline struct st_semaphore_object *
> +st_semaphore_object(struct gl_semaphore_object *obj)
> +{
> +   return (struct st_semaphore_object *)obj;
> +}
> +
> +extern void
> +st_init_semaphoreobject_functions(struct dd_function_table *functions);
> +
> +#endif
> diff --git a/src/mesa/state_tracker/st_context.c 
> b/src/mesa/state_tracker/st_context.c
> index 3ba4847926..f5a5b4fca7 100644
> --- a/src/mesa/state_tracker/st_context.c
> +++ b/src/mesa/state_tracker/st_context.c
> @@ -60,6 +60,7 @@
>  #include "st_cb_program.h"
>  #include "st_cb_queryobj.h"
>  #include "st_cb_readpixels.h"
> +#include "st_cb_semaphoreobjects.h"
>  #include "st_cb_texture.h"

[Mesa-dev] [PATCH] mesa: replace GLenum with GLenum16 in common structures (v4)

2018-01-29 Thread Brian Paul
From: Marek Olšák 

v2: - fix glGet*
- also use GLenum16 for DrawBuffers
v3: - rebase to top of tree (BrianP) and incorporate Ian's suggestions
v4: - fix a GLenum16 bug in VBO/save code, add some STATIC_ASSERT()s

gl_context = 152432 -> 136840 bytes
vbo_context = 22096 -> 20608 bytes

Reviewed-by: Brian Paul 
Reviewed-by: Nicolai Hähnle 
---
 src/mesa/drivers/common/meta.h |   2 +-
 src/mesa/drivers/dri/nouveau/nv04_state_frag.c |   4 +-
 src/mesa/drivers/dri/nouveau/nv10_state_frag.c |   4 +-
 src/mesa/main/attrib.c |  13 +-
 src/mesa/main/buffers.c|  12 +-
 src/mesa/main/buffers.h|   2 +-
 src/mesa/main/context.c|   2 +-
 src/mesa/main/get.c|  38 +
 src/mesa/main/get_hash_params.py   | 152 +-
 src/mesa/main/glheader.h   |   1 +
 src/mesa/main/mtypes.h | 204 -
 src/mesa/vbo/vbo_exec.h|   2 +-
 src/mesa/vbo/vbo_save.h|   4 +-
 src/mesa/vbo/vbo_save_api.c|   2 +
 src/mesa/vbo/vbo_save_draw.c   |   4 +-
 15 files changed, 250 insertions(+), 196 deletions(-)

diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 6d51854..3d9c291 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -190,7 +190,7 @@ struct save_state
struct gl_framebuffer *ReadBuffer;
 
/** MESA_META_DRAW_BUFFERS */
-   GLenum ColorDrawBuffers[MAX_DRAW_BUFFERS];
+   GLenum16 ColorDrawBuffers[MAX_DRAW_BUFFERS];
 };
 
 /**
diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c 
b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
index 248a7d2..bfe8eae 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
@@ -49,8 +49,8 @@ struct combiner_state {
 
/* GL state */
GLenum mode;
-   GLenum *source;
-   GLenum *operand;
+   GLenum16 *source;
+   GLenum16 *operand;
GLuint logscale;
 
/* Derived HW state */
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_frag.c 
b/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
index c6e4bb0..42dff08 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
@@ -67,8 +67,8 @@ struct combiner_state {
 
/* GL state */
GLenum mode;
-   GLenum *source;
-   GLenum *operand;
+   GLenum16 *source;
+   GLenum16 *operand;
GLuint logscale;
 
/* Derived HW state */
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 50b65c4..3c12fd6 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1005,11 +1005,16 @@ _mesa_PopAttrib(void)
* user FBO bound, GL_FRONT will be illegal and we'll need
* to record that error.  Per OpenGL ARB decision.
*/
-  if (multipleBuffers)
- _mesa_DrawBuffers(ctx->Const.MaxDrawBuffers,
-  color->DrawBuffer);
-  else
+  if (multipleBuffers) {
+ GLenum buffers[MAX_DRAW_BUFFERS];
+
+ for (unsigned i = 0; i < ctx->Const.MaxDrawBuffers; i++)
+buffers[i] = color->DrawBuffer[i];
+
+ _mesa_DrawBuffers(ctx->Const.MaxDrawBuffers, buffers);
+  } else {
  _mesa_DrawBuffer(color->DrawBuffer[0]);
+  }
}
_mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled);
_mesa_AlphaFunc(color->AlphaFunc, color->AlphaRefUnclamped);
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index d364047..5492227 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -299,7 +299,8 @@ draw_buffer(struct gl_context *ctx, struct gl_framebuffer 
*fb,
}
 
/* if we get here, there's no error so set new state */
-   _mesa_drawbuffers(ctx, fb, 1, &buffer, &destMask);
+   const GLenum16 buffer16 = buffer;
+   _mesa_drawbuffers(ctx, fb, 1, &buffer16, &destMask);
 
/* Call device driver function only if fb is the bound draw buffer */
if (fb == ctx->DrawBuffer) {
@@ -573,7 +574,11 @@ draw_buffers(struct gl_context *ctx, struct gl_framebuffer 
*fb, GLsizei n,
}
 
/* OK, if we get here, there were no errors so set the new state */
-   _mesa_drawbuffers(ctx, fb, n, buffers, destMask);
+   GLenum16 buffers16[MAX_DRAW_BUFFERS];
+   for (int i = 0; i < n; i++)
+  buffers16[i] = buffers[i];
+
+   _mesa_drawbuffers(ctx, fb, n, buffers16, destMask);
 
/*
 * Call device driver function if fb is the bound draw buffer.
@@ -694,7 +699,8 @@ updated_drawbuffers(struct gl_context *ctx, struct 
gl_framebuffer *fb)
  */
 void
 _mesa_drawb

[Mesa-dev] [PATCH v2 5/6] android: Change gralloc_handle_t format from Android format to fourcc

2018-01-29 Thread Robert Foss
Change the gralloc_handle_t format to signify the fourcc pixel format
code instead of the Android pixel format definition.

This is desirable since the fourcc code is what is used within the DRM
subsystem. Naturally translation will still have to happen somewhere.

Also bump the gralloc_handle_t version.

Sign-off-by: Robert Foss 
---
 android/gralloc_handle.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h
index 1e738017d9cb..d437f7648fad 100644
--- a/android/gralloc_handle.h
+++ b/android/gralloc_handle.h
@@ -57,7 +57,7 @@ struct gralloc_handle_t {
 
int width; /* width of buffer in pixels */
int height; /* height of buffer in pixels */
-   int format; /* pixel format (Android) */
+   int format; /* pixel format (fourcc) */
int usage; /* android libhardware usage flags */
 
int stride; /* the stride in bytes */
@@ -70,7 +70,7 @@ struct gralloc_handle_t {
} __attribute__((aligned(8)));
 };
 
-#define GRALLOC_HANDLE_VERSION 2
+#define GRALLOC_HANDLE_VERSION 3
 #define GRALLOC_HANDLE_MAGIC 0x60585350
 #define GRALLOC_HANDLE_NUM_FDS 1
 #define GRALLOC_HANDLE_NUM_INTS (  \
-- 
2.14.1

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


[Mesa-dev] [PATCH v2 2/6] android: Add version variable to gralloc_handle_t

2018-01-29 Thread Robert Foss
The version variable will be used for versioning of this
struct and the corresponding accessor functions.

Signed-off-by: Robert Foss 
---
 android/gralloc_handle.h | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h
index 770ee7adb4b5..8abc83de4626 100644
--- a/android/gralloc_handle.h
+++ b/android/gralloc_handle.h
@@ -28,6 +28,7 @@
 #define __ANDROID_GRALLOC_HANDLE_H__
 
 #include 
+#include 
 
 /* support users of drm_gralloc/gbm_gralloc */
 #define gralloc_gbm_handle_t gralloc_handle_t
@@ -50,7 +51,9 @@ struct gralloc_handle_t {
 */
int prime_fd;
 
+   /* api variables */
int magic; /* differentiate between allocator impls */
+   const uint32_t version; /* api version */
 
int width; /* width of buffer in pixels */
int height; /* height of buffer in pixels */
@@ -68,6 +71,7 @@ struct gralloc_handle_t {
} __attribute__((aligned(8)));
 };
 
+#define GRALLOC_HANDLE_VERSION 1
 #define GRALLOC_HANDLE_MAGIC 0x60585350
 #define GRALLOC_HANDLE_NUM_FDS 1
 #define GRALLOC_HANDLE_NUM_INTS (  \
@@ -80,7 +84,9 @@ struct gralloc_handle_t {
 static struct gralloc_handle_t gralloc_handle_create(int width, int height,
  int format, int usage)
 {
-   struct gralloc_handle_t handle = { .magic = GRALLOC_HANDLE_MAGIC };
+   struct alloc_handle_t handle = {
+   .magic = GRALLOC_HANDLE_MAGIC,
+   .version = GRALLOC_HANDLE_VERSION };
 
native_handle_t *nhandle = native_handle_create(GRALLOC_HANDLE_NUM_FDS,

GRALLOC_HANDLE_NUM_INTS);
-- 
2.14.1

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


[Mesa-dev] [PATCH v2 6/6] android: Change gralloc_handle_t members to be fixed width

2018-01-29 Thread Robert Foss
In order to lessen future alignment issues, lets switch to
fixed width integers where possible.

This excludes the data_owner since it is a pid_t which
in theory could be larger than 32 bits.

Signed-off-by: Robert Foss 
---
 android/gralloc_handle.h | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h
index d437f7648fad..695082a5004f 100644
--- a/android/gralloc_handle.h
+++ b/android/gralloc_handle.h
@@ -52,15 +52,15 @@ struct gralloc_handle_t {
int prime_fd;
 
/* api variables */
-   const int magic; /* differentiate between allocator impls */
+   const uint32_t magic; /* differentiate between allocator impls */
const uint32_t version; /* api version */
 
-   int width; /* width of buffer in pixels */
-   int height; /* height of buffer in pixels */
-   int format; /* pixel format (fourcc) */
-   int usage; /* android libhardware usage flags */
+   uint32_t width; /* width of buffer in pixels */
+   uint32_t height; /* height of buffer in pixels */
+   uint32_t format; /* pixel format (fourcc) */
+   uint32_t usage; /* android libhardware usage flags */
 
-   int stride; /* the stride in bytes */
+   uint32_t stride; /* the stride in bytes */
uint64_t modifier; /* buffer modifiers */
 
int data_owner; /* owner of data (for validation) */
@@ -70,7 +70,7 @@ struct gralloc_handle_t {
} __attribute__((aligned(8)));
 };
 
-#define GRALLOC_HANDLE_VERSION 3
+#define GRALLOC_HANDLE_VERSION 4
 #define GRALLOC_HANDLE_MAGIC 0x60585350
 #define GRALLOC_HANDLE_NUM_FDS 1
 #define GRALLOC_HANDLE_NUM_INTS (  \
@@ -80,8 +80,10 @@ struct gralloc_handle_t {
 /**
  * Create a buffer handle.
  */
-static struct gralloc_handle_t gralloc_handle_create(int width, int height,
- int format, int usage)
+static struct gralloc_handle_t gralloc_handle_create(int32_t width,
+ int32_t height,
+ int32_t format,
+ int32_t usage)
 {
struct alloc_handle_t handle = {
.magic = GRALLOC_HANDLE_MAGIC,
-- 
2.14.1

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


[Mesa-dev] [PATCH v2 1/6] android: Move gralloc handle struct to libdrm

2018-01-29 Thread Robert Foss
This struct is used in mesa and drm_hwcomposer.
Versions of if have been implemented in several grallocs:
drm_gralloc, gbm_gralloc, minigbm and intel-minigbm.

Other than the 1:1 move of the struct a new generic name
has been chosen and variables have had comments added to them.

Signed-off-by: Robert Foss 
---
Changes since v1:
 Suggested by Rob Herring:
 - Fixed copyright statement
 - Moved FDs to be first in handle
 - Initialize native_handle_t using native_handle_create()

 Android.mk   |   8 +++-
 Makefile.sources |   3 ++
 android/gralloc_handle.h | 102 +++
 3 files changed, 111 insertions(+), 2 deletions(-)
 create mode 100644 android/gralloc_handle.h

diff --git a/Android.mk b/Android.mk
index 292be2360263..8611c5e316d8 100644
--- a/Android.mk
+++ b/Android.mk
@@ -28,7 +28,7 @@ LIBDRM_TOP := $(LOCAL_PATH)
 
 include $(CLEAR_VARS)
 
-# Import variables LIBDRM_{,H_,INCLUDE_H_,INCLUDE_VMWGFX_H_}FILES
+# Import variables 
LIBDRM_{,H,INCLUDE_H,INCLUDE_ANDROID_H,INCLUDE_VMWGFX_H}_FILES
 include $(LOCAL_PATH)/Makefile.sources
 
 #static library for the device (recovery)
@@ -38,7 +38,8 @@ LOCAL_MODULE := libdrm
 LOCAL_SRC_FILES := $(LIBDRM_FILES)
 LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH) \
-   $(LOCAL_PATH)/include/drm
+   $(LOCAL_PATH)/include/drm \
+   $(LOCAL_PATH)/android
 
 LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include/drm
@@ -54,6 +55,9 @@ LOCAL_SRC_FILES := $(LIBDRM_FILES)
 LOCAL_EXPORT_C_INCLUDE_DIRS := \
 $(LOCAL_PATH)/include/drm
 
+LOCAL_SHARED_LIBRARIES := \
+   libcutils
+
 LOCAL_C_INCLUDES := \
 $(LOCAL_PATH)/include/drm
 
diff --git a/Makefile.sources b/Makefile.sources
index 10aa1d0f4b6e..1f8372bca183 100644
--- a/Makefile.sources
+++ b/Makefile.sources
@@ -37,5 +37,8 @@ LIBDRM_INCLUDE_H_FILES := \
include/drm/via_drm.h \
include/drm/virtgpu_drm.h
 
+LIBDRM_INCLUDE_ANDROID_H_FILES := \
+   android/gralloc_handle.h
+
 LIBDRM_INCLUDE_VMWGFX_H_FILES := \
include/drm/vmwgfx_drm.h
diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h
new file mode 100644
index ..770ee7adb4b5
--- /dev/null
+++ b/android/gralloc_handle.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2018 Robert Foss 
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE
+ * SOFTWARE.
+ *
+ * Authors:
+ *Robert Foss 
+ */
+
+#ifndef __ANDROID_GRALLOC_HANDLE_H__
+#define __ANDROID_GRALLOC_HANDLE_H__
+
+#include 
+
+/* support users of drm_gralloc/gbm_gralloc */
+#define gralloc_gbm_handle_t gralloc_handle_t
+#define gralloc_drm_handle_t gralloc_handle_t
+
+struct gralloc_handle_t {
+   native_handle_t base;
+
+   /* dma-buf file descriptor
+* Must be located first since, native_handle_t is allocated
+* using native_handle_create(), which allocates space for
+* sizeof(native_handle_t) + sizeof(int) * (numFds + numInts)
+* numFds = GRALLOC_HANDLE_NUM_FDS
+* numInts = GRALLOC_HANDLE_NUM_INTS
+* Where numFds represents the number of FDs and
+* numInts represents the space needed for the
+* remainder of this struct.
+* And the FDs are expected to be found first following
+* native_handle_t.
+*/
+   int prime_fd;
+
+   int magic; /* differentiate between allocator impls */
+
+   int width; /* width of buffer in pixels */
+   int height; /* height of buffer in pixels */
+   int format; /* pixel format (Android) */
+   int usage; /* android libhardware usage flags */
+
+   int name;   /* the name of the bo */
+   int stride; /* the stride in bytes */
+   uint64_t modifier; /* buffer modifiers */
+
+   int data_owner; /* owner of data (for validation) */
+   union {
+   void *data; /* pointer to struct gralloc_gbm_bo_t */
+   uint64_t reserved;
+   } __attribute__((aligned

[Mesa-dev] [PATCH v2 4/6] android: Remove member name from gralloc_handle_t

2018-01-29 Thread Robert Foss
The name member of gralloc_handle_t is no longer needed and has been removed.
The version field has also been bumped.

Signed-off-by: Robert Foss 
---
 android/gralloc_handle.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h
index 64196c0b40e7..1e738017d9cb 100644
--- a/android/gralloc_handle.h
+++ b/android/gralloc_handle.h
@@ -60,7 +60,6 @@ struct gralloc_handle_t {
int format; /* pixel format (Android) */
int usage; /* android libhardware usage flags */
 
-   int name;   /* the name of the bo */
int stride; /* the stride in bytes */
uint64_t modifier; /* buffer modifiers */
 
@@ -71,7 +70,7 @@ struct gralloc_handle_t {
} __attribute__((aligned(8)));
 };
 
-#define GRALLOC_HANDLE_VERSION 1
+#define GRALLOC_HANDLE_VERSION 2
 #define GRALLOC_HANDLE_MAGIC 0x60585350
 #define GRALLOC_HANDLE_NUM_FDS 1
 #define GRALLOC_HANDLE_NUM_INTS (  \
-- 
2.14.1

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


[Mesa-dev] [PATCH v2 3/6] android: Mark gralloc_handle_t magic variable as const

2018-01-29 Thread Robert Foss
Mark magic member of gralloc_handle_t as const.

Sign-off-by: Robert Foss 
Signed-off-by: Robert Foss 
---
 android/gralloc_handle.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h
index 8abc83de4626..64196c0b40e7 100644
--- a/android/gralloc_handle.h
+++ b/android/gralloc_handle.h
@@ -52,7 +52,7 @@ struct gralloc_handle_t {
int prime_fd;
 
/* api variables */
-   int magic; /* differentiate between allocator impls */
+   const int magic; /* differentiate between allocator impls */
const uint32_t version; /* api version */
 
int width; /* width of buffer in pixels */
-- 
2.14.1

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


[Mesa-dev] [PATCH v2 0/6] Implement commont gralloc_handle_t in libdrm

2018-01-29 Thread Robert Foss
This series moves {gbm,drm,cros}_gralloc_handle_t struct to libdrm,
since at least 4 implementations exist, and share a lot of contents.
The idea is to keep the common stuff defined in one place, and libdrm
is the common codebase to all of these platforms.

Additionally, having this struct defined in libdrm will make it
easier for mesa and gralloc implementations to communicate.

A second series is expected to be submitted, which will contain an accessor
function implementation that should that would allow each gralloc to
implementation to supply their own accessors.

Robert Foss (6):
  android: Move gralloc handle struct to libdrm
  android: Add version variable to gralloc_handle_t
  android: Mark gralloc_handle_t magic variable as const
  android: Remove member name from gralloc_handle_t
  android: Change gralloc_handle_t format from Android format to fourcc
  android: Change gralloc_handle_t members to be fixed width

 Android.mk   |   8 +++-
 Makefile.sources |   3 ++
 android/gralloc_handle.h | 109 +++
 3 files changed, 118 insertions(+), 2 deletions(-)
 create mode 100644 android/gralloc_handle.h

-- 
2.14.1

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


Re: [Mesa-dev] [RFC][PATCH xserver] Multi-buffered flips on subsurfaces seg fault in Mesa

2018-01-29 Thread Roman Gilg
Sorry, somewhat part of my message got removed. It should begin with:

"This is a RFC on a follow-up patch to my recently posted patch series on
the
xorg-devel mailing list to enable per window flips of Present Pixmaps to
Wayland surfaces:
https://lists.freedesktop.org/archives/xorg-devel/2018-January/055674.html

The above patch series only allows flips..."

and so on.

On Mon, Jan 29, 2018 at 5:54 PM, Roman Gilg  wrote:

> The above patch series only allows flips on a child window with the same
> dimensions as its parent xwl_window. For flips on child windows (for
> example
> the video view port of a video player in windowed mode, see here:
> http://www.subdiff.de/assets/images/2017-07-28-a-new-beginning.jpg) I
> wanted
> to use Wayland subsurfaces as in the attached patch.
>
> The flipping itself works well on Weston and on KWin. But when shutting
> down
> KWin in the end I get always a segmentation fault in Mesa when cleaning up
> EGL
> via eglTerminate(EGLDisplay) through libepoxy.
>
> I pinpointed the seg fault to be a missing destroyImage function pointer
> here:
> https://cgit.freedesktop.org/mesa/mesa/tree/src/egl/
> drivers/dri2/egl_dri2.c#n2685
>
> But I don't see currently what component is making the problems here or if
> the
> problem lies in my code.
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


  1   2   >