Re: [Mesa-dev] i965: Transition the rest of surfaces (i.e., color) to isl

2017-07-30 Thread Tapani Pälli



On 07/29/2017 08:21 AM, Jason Ekstrand wrote:
On Fri, Jul 28, 2017 at 10:14 PM, Tomasz Figa > wrote:


On Sat, Jul 29, 2017 at 2:06 PM, Jason Ekstrand
> wrote:
 > On Fri, Jul 28, 2017 at 8:17 PM, Tomasz Figa > wrote:
 >>
 >> Hi Topi, Jason,
 >>
 >> On Sat, Jul 22, 2017 at 12:00 AM, Topi Pohjolainen
 >> >
wrote:
 >> > First patch actually should have been included already when
 >> > gen6 stencil got transitioned - it has been giving warning ever
 >> > since.
 >> >
 >> > Most of the work actually got already done for depth surfaces
(which
 >> > is y-tiled such as color surfaces). What is left are color surface
 >> > specifics, mostly preparing for corner cases.
 >> >
 >> > This is now all green in ci-system. For snb and older i965 wasn't
 >> > checking hardware incapabilities as hard as isl does. Certain
 >> > format/size/msaa combinations were allowed that shouldn't have.
 >> > Moving to isl exposed code paths that didn't report surface
creation
 >> > failures resulting in asserts firing later on. Patches 10 and 11
 >> > now properly tell the client if the surface type can't be
supported
 >> > allowing piglit tests to skip them.
 >>
 >> I think it might be related to previously merged patches, but the
 >> topic is still ISL, so let me ask my question here. Is there any
 >> possibility to add some diagnostic information to the validation
code?
 >> We've been seeing EGL image import failures on new Mesa as a
result of
 >> ISL catching issues in our allocator (cros_gralloc on top of
ChromeOS
 >> minigbm), but it's close to impossible to identify the cause without
 >> manually inserting some printfs and recompiling the code. I think
 >> having some error messages printed in case of a buffer validation
 >> failure would be a great benefit.
 >
 >
 > What kind of prints are you looking for exactly?  I've run into
some issues
 > myself but if you could provide a concrete example, that would help.

For example, we hit two different issues where the total size check in
intel_create_image_from_fds_common() was failing and the only way to
figure out the exact reason was digging deep into the calculations in
ISL:

1) missing 64-byte padding from the end of linear buffers,

2) (total) height of the buffer not aligned to 4-lines - actually the
problem is much more interesting, because this was specifically with
Android's HAL_PIXEL_FORMAT_YV12 (3-plane YVU420), which doesn't permit
height alignment higher than 2 defined by the spec. Mesa seems to care
about total size of the buffer only, so we could work around this by
simply adding enough padding at the end of the buffer.


Right... I was concerned about that when I landed those changes but 
never saw a problem in my testing (probably due to piglit always 
choosing "nice" sizes).  I've considered simply deleting that code from 
ISL because I'm not at all convinced that it's needed.  Chad, do you 
have any thoughts on this?  my understanding is that the padding is only 
needed to avoid page faults in the GPU and, since every byte of our 
address space has pages (thanks to the scratch page) this shouldn't 
actually be a problem.




Please CC me if some of these restrictions will be removed, we applied 
fixes for these in minigbm when Mesa was rebased in Android-IA.


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


Re: [Mesa-dev] [PATCH] radv: Don't underflow non-visible VRAM size.

2017-07-30 Thread Michel Dänzer
On 31/07/17 06:29 AM, Bas Nieuwenhuizen wrote:
> n some APU situations the reported visible size can be larger than

Missing "I" at the beginning, vim fail? :)


> VRAM size. This properly clamps the value.
> 
> Surprisingly both CTS and spec seem to allow a heap type with size 0,
> so this seemed like the easiest option to me.
> 
> Signed-off-by: Bas Nieuwenhuizen 
> Fixes: 4ae84efbc5c "radv: Use enum for memory heaps."
> ---
>  src/amd/vulkan/radv_device.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
> index 5244c157c35..b3041b9a47f 100644
> --- a/src/amd/vulkan/radv_device.c
> +++ b/src/amd/vulkan/radv_device.c
> @@ -928,15 +928,17 @@ void radv_GetPhysicalDeviceMemoryProperties(
>   };
>  
>   STATIC_ASSERT(RADV_MEM_HEAP_COUNT <= VK_MAX_MEMORY_HEAPS);
> + uint64_t visible_vram_size = MIN2(physical_device->rad_info.vram_size,
> +   
> physical_device->rad_info.vram_vis_size);
>  
>   pMemoryProperties->memoryHeapCount = RADV_MEM_HEAP_COUNT;
>   pMemoryProperties->memoryHeaps[RADV_MEM_HEAP_VRAM] = (VkMemoryHeap) {
>   .size = physical_device->rad_info.vram_size -
> - physical_device->rad_info.vram_vis_size,
> + visible_vram_size,
>   .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
>   };
>   pMemoryProperties->memoryHeaps[RADV_MEM_HEAP_VRAM_CPU_ACCESS] = 
> (VkMemoryHeap) {
> - .size = physical_device->rad_info.vram_vis_size,
> + .size = visible_vram_size,
>   .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
>   };
>   pMemoryProperties->memoryHeaps[RADV_MEM_HEAP_GTT] = (VkMemoryHeap) {
> 

Reviewed-and-Tested-by: Michel Dänzer 


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


Re: [Mesa-dev] [PATCH 1/1] gallium, clover: Wait for requested operation if blocking flag is set

2017-07-30 Thread Aaron Watry
What's here is:
Reviewed-By: Aaron Watry 

That being said, are clEnqueueMapBuffer/clEnqueueMapImage still
affected or are those always done as blocking operations and my c++ is
weak?

--Aaron

On Fri, Jul 28, 2017 at 10:36 PM, Jan Vesely  wrote:
> Signed-off-by: Jan Vesely 
> ---
> Found by inspection. Fixes clRetain/clRelease event piglit on Turks, no
> regressions.
>
>  src/gallium/state_trackers/clover/api/transfer.cpp | 18 ++
>  1 file changed, 18 insertions(+)
>
> diff --git a/src/gallium/state_trackers/clover/api/transfer.cpp 
> b/src/gallium/state_trackers/clover/api/transfer.cpp
> index f7046253be..2af28b1e94 100644
> --- a/src/gallium/state_trackers/clover/api/transfer.cpp
> +++ b/src/gallium/state_trackers/clover/api/transfer.cpp
> @@ -295,6 +295,9 @@ clEnqueueReadBuffer(cl_command_queue d_q, cl_mem d_mem, 
> cl_bool blocking,
> , obj_origin, obj_pitch,
> region));
>
> +   if (blocking)
> +   hev().wait();
> +
> ret_object(rd_ev, hev);
> return CL_SUCCESS;
>
> @@ -325,6 +328,9 @@ clEnqueueWriteBuffer(cl_command_queue d_q, cl_mem d_mem, 
> cl_bool blocking,
> ptr, {}, obj_pitch,
> region));
>
> +   if (blocking)
> +   hev().wait();
> +
> ret_object(rd_ev, hev);
> return CL_SUCCESS;
>
> @@ -362,6 +368,9 @@ clEnqueueReadBufferRect(cl_command_queue d_q, cl_mem 
> d_mem, cl_bool blocking,
> , obj_origin, obj_pitch,
> region));
>
> +   if (blocking)
> +   hev().wait();
> +
> ret_object(rd_ev, hev);
> return CL_SUCCESS;
>
> @@ -399,6 +408,9 @@ clEnqueueWriteBufferRect(cl_command_queue d_q, cl_mem 
> d_mem, cl_bool blocking,
> ptr, host_origin, host_pitch,
> region));
>
> +   if (blocking)
> +   hev().wait();
> +
> ret_object(rd_ev, hev);
> return CL_SUCCESS;
>
> @@ -504,6 +516,9 @@ clEnqueueReadImage(cl_command_queue d_q, cl_mem d_mem, 
> cl_bool blocking,
> , src_origin, src_pitch,
> region));
>
> +   if (blocking)
> +   hev().wait();
> +
> ret_object(rd_ev, hev);
> return CL_SUCCESS;
>
> @@ -538,6 +553,9 @@ clEnqueueWriteImage(cl_command_queue d_q, cl_mem d_mem, 
> cl_bool blocking,
> ptr, {}, src_pitch,
> region));
>
> +   if (blocking)
> +   hev().wait();
> +
> ret_object(rd_ev, hev);
> return CL_SUCCESS;
>
> --
> 2.13.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 5/8] clover/llvm: Use device in llvm compilation instead of copying fields

2017-07-30 Thread Aaron Watry
Copying the individual fields from the device when compiling/linking
will lead to an unnecessarily large number of fields getting passed
around.

Signed-off-by: Aaron Watry 
Cc: Jan Vesey 
---
 src/gallium/state_trackers/clover/core/program.cpp |  9 +++--
 .../state_trackers/clover/llvm/invocation.cpp  | 22 ++
 .../state_trackers/clover/llvm/invocation.hpp  |  7 ++-
 3 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
b/src/gallium/state_trackers/clover/core/program.cpp
index f0f0f38548..4e74fccd97 100644
--- a/src/gallium/state_trackers/clover/core/program.cpp
+++ b/src/gallium/state_trackers/clover/core/program.cpp
@@ -53,9 +53,8 @@ program::compile(const ref_vector , const 
std::string ,
  try {
 const module m = (dev.ir_format() == PIPE_SHADER_IR_TGSI ?
   tgsi::compile_program(_source, log) :
-  llvm::compile_program(_source, headers,
-dev.ir_target(), opts,
-dev.device_clc_version(), 
log));
+  llvm::compile_program(_source, headers, dev,
+opts, log));
 _builds[] = { m, opts, log };
  } catch (...) {
 _builds[] = { module(), opts, log };
@@ -79,9 +78,7 @@ program::link(const ref_vector , const 
std::string ,
   try {
  const module m = (dev.ir_format() == PIPE_SHADER_IR_TGSI ?
tgsi::link_program(ms) :
-   llvm::link_program(ms, dev.ir_format(),
-  dev.ir_target(), opts,
-  dev.device_clc_version(), log));
+   llvm::link_program(ms, dev, opts, log));
  _builds[] = { m, opts, log };
   } catch (...) {
  _builds[] = { module(), opts, log };
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index ca75596b05..e761ca188d 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -261,17 +261,16 @@ namespace {
 module
 clover::llvm::compile_program(const std::string ,
   const header_map ,
-  const std::string ,
+  const device ,
   const std::string ,
-  const std::string _version,
   std::string _log) {
if (has_flag(debug::clc))
   debug::log(".cl", "// Options: " + opts + '\n' + source);
 
auto ctx = create_context(r_log);
-   auto c = create_compiler_instance(target, tokenize(opts + " input.cl"),
- device_version, r_log);
-   auto mod = compile(*ctx, *c, "input.cl", source, headers, target, opts,
+   auto c = create_compiler_instance(dev.ir_target(), tokenize(opts + " 
input.cl"),
+ dev.device_clc_version(), r_log);
+   auto mod = compile(*ctx, *c, "input.cl", source, headers, dev.ir_target(), 
opts,
   r_log);
 
if (has_flag(debug::llvm))
@@ -330,16 +329,15 @@ namespace {
 
 module
 clover::llvm::link_program(const std::vector ,
-   enum pipe_shader_ir ir, const std::string ,
+   const device ,
const std::string ,
-   const std::string _version,
std::string _log) {
std::vector options = tokenize(opts + " input.cl");
const bool create_library = count("-create-library", options);
erase_if(equals("-create-library"), options);
 
auto ctx = create_context(r_log);
-   auto c = create_compiler_instance(target, options, device_version, r_log);
+   auto c = create_compiler_instance(dev.ir_target(), options, 
dev.device_clc_version(), r_log);
auto mod = link(*ctx, *c, modules, r_log);
 
optimize(*mod, c->getCodeGenOpts().OptimizationLevel, !create_library);
@@ -354,14 +352,14 @@ clover::llvm::link_program(const std::vector 
,
if (create_library) {
   return build_module_library(*mod, module::section::text_library);
 
-   } else if (ir == PIPE_SHADER_IR_LLVM) {
+   } else if (dev.ir_format() == PIPE_SHADER_IR_LLVM) {
   return build_module_bitcode(*mod, *c);
 
-   } else if (ir == PIPE_SHADER_IR_NATIVE) {
+   } else if (dev.ir_format() == PIPE_SHADER_IR_NATIVE) {
   if (has_flag(debug::native))
- debug::log(id +  ".asm", print_module_native(*mod, target));
+ debug::log(id +  ".asm", print_module_native(*mod, dev.ir_target()));
 
-  return build_module_native(*mod, target, *c, r_log);
+  

[Mesa-dev] [PATCH 8/8] clover/llvm: Make __OPENCL_VERSION__ dynamic

2017-07-30 Thread Aaron Watry
Signed-off-by: Aaron Watry 
CC: Jan Vesely 

v2: base it on the device version
---
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 63b2961752..443cd31e66 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -224,7 +224,8 @@ namespace {
   c.getPreprocessorOpts().Includes.push_back("clc/clc.h");
 
   // Add definition for the OpenCL version
-  c.getPreprocessorOpts().addMacroDef("__OPENCL_VERSION__=110");
+  c.getPreprocessorOpts().addMacroDef("__OPENCL_VERSION__=" +
+  
std::to_string(get_language_from_version_str(dev.device_version(;
 
   // clc.h requires that this macro be defined:
   c.getPreprocessorOpts().addMacroDef("cl_clang_storage_class_specifiers");
-- 
2.11.0

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


[Mesa-dev] [PATCH 7/8] clover/llvm: validate requested cl-std against device_clc_version

2017-07-30 Thread Aaron Watry
Signed-off-by: Aaron Watry 
Cc: Pierre Moreau 
---
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 16966bedb3..63b2961752 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -145,6 +145,11 @@ namespace {
  auto pos = opt.find(search);
  if (pos == 0){
 auto ver = opt.substr(pos+search.size());
+auto device_ver = get_language_version_from_string(device_version);
+auto requested = get_language_version_from_string(ver);
+if (requested > device_ver) {
+   throw build_error();
+}
 return get_language_from_version_str(ver, true);
  }
   }
-- 
2.11.0

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


[Mesa-dev] [PATCH 6/8] clover/llvm: Pass device down to compile

2017-07-30 Thread Aaron Watry
We'll need to be able to detect device version to define the appropriate
__OPENCL_VERSION__ header.

Signed-off-by: Aaron Watry 
---
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index e761ca188d..16966bedb3 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -203,7 +203,7 @@ namespace {
std::unique_ptr
compile(LLVMContext , clang::CompilerInstance ,
const std::string , const std::string ,
-   const header_map , const std::string ,
+   const header_map , const device ,
const std::string , std::string _log) {
   c.getFrontendOpts().ProgramAction = clang::frontend::EmitLLVMOnly;
   c.getHeaderSearchOpts().UseBuiltinIncludes = true;
@@ -247,7 +247,7 @@ namespace {
   // barrier() (e.g. Moving barrier() inside a conditional that is
   // no executed by all threads) during its optimizaton passes.
   compat::add_link_bitcode_file(c.getCodeGenOpts(),
-LIBCLC_LIBEXECDIR + target + ".bc");
+LIBCLC_LIBEXECDIR + dev.ir_target() + 
".bc");
 
   // Compile the code
   clang::EmitLLVMOnlyAction act();
@@ -270,7 +270,7 @@ clover::llvm::compile_program(const std::string ,
auto ctx = create_context(r_log);
auto c = create_compiler_instance(dev.ir_target(), tokenize(opts + " 
input.cl"),
  dev.device_clc_version(), r_log);
-   auto mod = compile(*ctx, *c, "input.cl", source, headers, dev.ir_target(), 
opts,
+   auto mod = compile(*ctx, *c, "input.cl", source, headers, dev, opts,
   r_log);
 
if (has_flag(debug::llvm))
-- 
2.11.0

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


[Mesa-dev] [PATCH 4/8] clover/llvm: Use -cl-std and device version to select language defaults

2017-07-30 Thread Aaron Watry
According to section 5.8.4.5 of the 2.0 spec, the CL C version is chosen by:
 1) If you have -cl-std=CL1.1+ use the version specified
 2) If not, use the highest 1.x version that the device supports

Curiously, there is no valid value for -cl-std=CL1.0

Signed-off-by: Aaron Watry 
Cc: Pierre Moreau 

v2: (Pierre) Move create_compiler_instance changes to correct patch
to prevent temporary build breakage.
Convert version_str into unsigned and use it to find language version
Add build_error for unknown language version string
Whitespace fixes
---
 .../state_trackers/clover/llvm/invocation.cpp  | 61 +-
 1 file changed, 60 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 7c8d0e738d..ca75596b05 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -93,6 +93,65 @@ namespace {
   return ctx;
}
 
+   unsigned get_language_version_from_string(const std::string _str){
+  if (version_str == "1.0"){
+ return 100;
+  }
+  if (version_str == "1.1"){
+ return 110;
+  }
+  if (version_str == "1.2"){
+ return 120;
+  }
+  if (version_str == "2.0"){
+ return 200;
+  }
+  throw build_error("Unknown/Unsupported language version");
+   }
+
+   clang::LangStandard::Kind
+   get_language_from_version_str(const std::string _str,
+ bool is_opt = false) {
+   /**
+* Per CL 2.0 spec, section 5.8.4.5:
+* If it's an option, use the value directly.
+* If it's a device version, clamp to max 1.x version, a.k.a. 1.2
+*/
+  unsigned version = get_language_version_from_string(version_str);
+  if (!is_opt && version > 120 ){
+ version = 120;
+  }
+  switch (version){
+ case 100:
+return clang::LangStandard::lang_opencl10;
+ case 110:
+return clang::LangStandard::lang_opencl11;
+ case 120:
+return clang::LangStandard::lang_opencl12;
+ case 200:
+return clang::LangStandard::lang_opencl20;
+ default:
+throw build_error("Unknown/Unsupported language version");
+  }
+   }
+
+   clang::LangStandard::Kind
+   get_language_version(const std::vector ,
+const std::string _version) {
+
+  const std::string search = "-cl-std=CL";
+
+  for(auto opt: opts){
+ auto pos = opt.find(search);
+ if (pos == 0){
+auto ver = opt.substr(pos+search.size());
+return get_language_from_version_str(ver, true);
+ }
+  }
+
+  return get_language_from_version_str(device_version);
+   }
+
std::unique_ptr
create_compiler_instance(const target ,
 const std::vector ,
@@ -129,7 +188,7 @@ namespace {
   compat::set_lang_defaults(c->getInvocation(), c->getLangOpts(),
 compat::ik_opencl, 
::llvm::Triple(target.triple),
 c->getPreprocessorOpts(),
-clang::LangStandard::lang_opencl11);
+get_language_version(opts, device_version));
 
   c->createDiagnostics(new clang::TextDiagnosticPrinter(
   *new raw_string_ostream(r_log),
-- 
2.11.0

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


[Mesa-dev] [PATCH 3/8] clover: Add device_clc_version to llvm::[compile|link]_program

2017-07-30 Thread Aaron Watry
We'll be using it to select the default language version soon.

Signed-off-by: Aaron Watry 
Cc: Pierre Moreau 
Cc: Jan Vesely 

v2: (Pierre) Move changes to create_compiler_instance invocation to correct
patch to prevent temporary build breakage.
(Jan) Use device_clc_version instead of device_version for compile/link
---
 src/gallium/state_trackers/clover/core/program.cpp|  6 --
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 10 +++---
 src/gallium/state_trackers/clover/llvm/invocation.hpp |  2 ++
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
b/src/gallium/state_trackers/clover/core/program.cpp
index ae4b50a879..f0f0f38548 100644
--- a/src/gallium/state_trackers/clover/core/program.cpp
+++ b/src/gallium/state_trackers/clover/core/program.cpp
@@ -54,7 +54,8 @@ program::compile(const ref_vector , const 
std::string ,
 const module m = (dev.ir_format() == PIPE_SHADER_IR_TGSI ?
   tgsi::compile_program(_source, log) :
   llvm::compile_program(_source, headers,
-dev.ir_target(), opts, 
log));
+dev.ir_target(), opts,
+dev.device_clc_version(), 
log));
 _builds[] = { m, opts, log };
  } catch (...) {
 _builds[] = { module(), opts, log };
@@ -79,7 +80,8 @@ program::link(const ref_vector , const 
std::string ,
  const module m = (dev.ir_format() == PIPE_SHADER_IR_TGSI ?
tgsi::link_program(ms) :
llvm::link_program(ms, dev.ir_format(),
-  dev.ir_target(), opts, log));
+  dev.ir_target(), opts,
+  dev.device_clc_version(), log));
  _builds[] = { m, opts, log };
   } catch (...) {
  _builds[] = { module(), opts, log };
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 6412377faa..7c8d0e738d 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -96,6 +96,7 @@ namespace {
std::unique_ptr
create_compiler_instance(const target ,
 const std::vector ,
+const std::string _version,
 std::string _log) {
   std::unique_ptr c { new clang::CompilerInstance 
};
   clang::TextDiagnosticBuffer *diag_buffer = new 
clang::TextDiagnosticBuffer;
@@ -203,13 +204,14 @@ clover::llvm::compile_program(const std::string ,
   const header_map ,
   const std::string ,
   const std::string ,
+  const std::string _version,
   std::string _log) {
if (has_flag(debug::clc))
   debug::log(".cl", "// Options: " + opts + '\n' + source);
 
auto ctx = create_context(r_log);
auto c = create_compiler_instance(target, tokenize(opts + " input.cl"),
- r_log);
+ device_version, r_log);
auto mod = compile(*ctx, *c, "input.cl", source, headers, target, opts,
   r_log);
 
@@ -270,13 +272,15 @@ namespace {
 module
 clover::llvm::link_program(const std::vector ,
enum pipe_shader_ir ir, const std::string ,
-   const std::string , std::string _log) {
+   const std::string ,
+   const std::string _version,
+   std::string _log) {
std::vector options = tokenize(opts + " input.cl");
const bool create_library = count("-create-library", options);
erase_if(equals("-create-library"), options);
 
auto ctx = create_context(r_log);
-   auto c = create_compiler_instance(target, options, r_log);
+   auto c = create_compiler_instance(target, options, device_version, r_log);
auto mod = link(*ctx, *c, modules, r_log);
 
optimize(*mod, c->getCodeGenOpts().OptimizationLevel, !create_library);
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.hpp 
b/src/gallium/state_trackers/clover/llvm/invocation.hpp
index 5b3530c382..959ef755b1 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.hpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.hpp
@@ -34,12 +34,14 @@ namespace clover {
  const header_map ,
  const std::string ,
  const std::string ,
+ const std::string _version,

[Mesa-dev] [PATCH 2/8] clover: Add device_clc_version to device.[hc]pp

2017-07-30 Thread Aaron Watry
device_version and device_clc_version are not necessarily the same for
devices that support CL 1.0, but have a 1.1 compiler and the necessary
extensions.

CC: Jan Vesey 
---
 src/gallium/state_trackers/clover/api/device.cpp  | 2 +-
 src/gallium/state_trackers/clover/core/device.cpp | 5 +
 src/gallium/state_trackers/clover/core/device.hpp | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
b/src/gallium/state_trackers/clover/api/device.cpp
index 18ed2f059f..b1b7917e4e 100644
--- a/src/gallium/state_trackers/clover/api/device.cpp
+++ b/src/gallium/state_trackers/clover/api/device.cpp
@@ -368,7 +368,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
   break;
 
case CL_DEVICE_OPENCL_C_VERSION:
-  buf.as_string() = "OpenCL C " + dev.device_version() + " ";
+  buf.as_string() = "OpenCL C " + dev.device_clc_version() + " ";
   break;
 
case CL_DEVICE_PRINTF_BUFFER_SIZE:
diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
b/src/gallium/state_trackers/clover/core/device.cpp
index 0277495506..68856ae36b 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -245,3 +245,8 @@ std::string
 device::device_version() const {
 return "1.1";
 }
+
+std::string
+device::device_clc_version() const {
+return "1.1";
+}
diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
b/src/gallium/state_trackers/clover/core/device.hpp
index 3cf7e20be5..efc217aedb 100644
--- a/src/gallium/state_trackers/clover/core/device.hpp
+++ b/src/gallium/state_trackers/clover/core/device.hpp
@@ -75,6 +75,7 @@ namespace clover {
   std::string device_name() const;
   std::string vendor_name() const;
   std::string device_version() const;
+  std::string device_clc_version() const;
   enum pipe_shader_ir ir_format() const;
   std::string ir_target() const;
   enum pipe_endian endianness() const;
-- 
2.11.0

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


[Mesa-dev] [PATCH 1/8] clover/device: Move device version into core/device.cpp

2017-07-30 Thread Aaron Watry
The device version is the maximum CL version that the device supports.

Eventually, this will be based on the features/extensions of the actual
device, but for now move it a bit closer to its eventual destination.

Signed-off-by: Aaron Watry 
---
 src/gallium/state_trackers/clover/api/device.cpp  | 4 ++--
 src/gallium/state_trackers/clover/core/device.cpp | 5 +
 src/gallium/state_trackers/clover/core/device.hpp | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
b/src/gallium/state_trackers/clover/api/device.cpp
index 0b33350bb2..18ed2f059f 100644
--- a/src/gallium/state_trackers/clover/api/device.cpp
+++ b/src/gallium/state_trackers/clover/api/device.cpp
@@ -314,7 +314,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
   break;
 
case CL_DEVICE_VERSION:
-  buf.as_string() = "OpenCL 1.1 Mesa " PACKAGE_VERSION
+  buf.as_string() = "OpenCL " + dev.device_version() + " Mesa " 
PACKAGE_VERSION
 #ifdef MESA_GIT_SHA1
 " (" MESA_GIT_SHA1 ")"
 #endif
@@ -368,7 +368,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
   break;
 
case CL_DEVICE_OPENCL_C_VERSION:
-  buf.as_string() = "OpenCL C 1.1 ";
+  buf.as_string() = "OpenCL C " + dev.device_version() + " ";
   break;
 
case CL_DEVICE_PRINTF_BUFFER_SIZE:
diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
b/src/gallium/state_trackers/clover/core/device.cpp
index 2ad9e49cf8..0277495506 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -240,3 +240,8 @@ enum pipe_endian
 device::endianness() const {
return (enum pipe_endian)pipe->get_param(pipe, PIPE_CAP_ENDIANNESS);
 }
+
+std::string
+device::device_version() const {
+return "1.1";
+}
diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
b/src/gallium/state_trackers/clover/core/device.hpp
index 7b3353df34..3cf7e20be5 100644
--- a/src/gallium/state_trackers/clover/core/device.hpp
+++ b/src/gallium/state_trackers/clover/core/device.hpp
@@ -74,6 +74,7 @@ namespace clover {
   cl_uint address_bits() const;
   std::string device_name() const;
   std::string vendor_name() const;
+  std::string device_version() const;
   enum pipe_shader_ir ir_format() const;
   std::string ir_target() const;
   enum pipe_endian endianness() const;
-- 
2.11.0

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


[Mesa-dev] [PATCH 0/8 v2] A few clover fixes for both CTS and eventual 1.2 support

2017-07-30 Thread Aaron Watry
I've dropped the first patch of the previous series for now. I'm not
withdrawing it completely, just going to see if there's anything about
the user_ptr stuff that could have been causing the issue instead, and
if I'm using too big a hammer in this patch. If I convince myself of its
correctness, it'll be back.

The rest of the patches move the device version declaration to core/device
and then use that along with the -cl-std option to determine which
OpenCL language version to enable in clang.

I've done a full piglit run (again) before/after, and there are no changes
for me on radeonsi/pitcairn if the device is left at CL 1.1.

When I bump my platform/device versions to 1.2, the clang instance has
been confirmed to enable 1.2 language features (like the static keyword
required in test/cl/program/execute/static.cl, which goes skip->pass).

Major changes since v1:
  Addressed Pierre's build-breakage comments
  Added a check for cl-std > device_clc_version
  Added a patch to pass the device object down into invocation.cpp
instead of adding a bunch of device-based arguments.
  Use device_clc_version for cl version detection instead of device_version
  Added device_clc_version in device.cpp/hpp

Anyway, happy reviewing.

Cc: Jan Vesely 
Cc: Pierre Moreau 

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


Re: [Mesa-dev] [PATCH] st/dri: enable 32-bit RGBX/RGBA formats only on Android

2017-07-30 Thread Marek Olšák
On Sun, Jul 30, 2017 at 4:44 AM, Tomasz Figa  wrote:

> On Sun, Jul 30, 2017 at 6:51 AM, Marek Olšák  wrote:
> > Hi Tomasz,
> >
> > This is for 17.2 only. Not master. I have a different fix for master.
>
> Right, we don't need this in master, but according to
> https://www.mesa3d.org/submittingpatches.html, the "Criteria for
> accepting patches to the stable branch" section, "Patch must have
> landed in master first.". IMHO it wouldn't make much sense to put this
> one in master, but I guess it wouldn't hurt either if we replace it
> with your patch after that.
>

OK. In that case we also need to change submittingpatches.html to allow
sending commits directly to stable without committing to master.

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


Re: [Mesa-dev] [PATCH v2] st/dri: add 32-bit RGBX/RGBA formats

2017-07-30 Thread Marek Olšák
On Sun, Jul 30, 2017 at 5:49 PM, Chih-Wei Huang 
wrote:

> 2017-07-28 22:59 GMT+08:00 Marek Olšák :
> > Hi,
> >
> > I've sent a request to revert this commit in 17.2. I'll keep it in
> > master, but I'll add a fix not to expose the new formats for GLX.
>
> I thought it doesn't break GLX according to
> the commit message (investigation by Chad Versace).
> Isn't it correct?
>

The commit message is wrong. The GLX visuals are exposed, which means any
app can use them.

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


Re: [Mesa-dev] [PATCH 2/3] glsl: tidy up get_num_operands()

2017-07-30 Thread Timothy Arceri

On 31/07/17 08:51, Ilia Mirkin wrote:



On Jul 30, 2017 5:38 PM, "Timothy Arceri" > wrote:


Also add a comment that this should only be used by the ir_reader
interface for testing purposes.
---
  src/compiler/glsl/ir.cpp |  8 ++--
  src/compiler/glsl/ir.h   | 14 +++---
  2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index d501e19c01..750582e40e 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -549,38 +549,42 @@ ir_expression::ir_expression(int op, ir_rvalue
*op0, ir_rvalue *op1,
 case ir_triop_csel:
this->type = op1->type;
break;

 default:
assert(!"not reached: missing automatic type setup for
ir_expression");
this->type = glsl_type::float_type;
 }
  }

-unsigned int
+/**
+ * This is only here for ir_reader to used for testing purposes
please use
+ * the precomputed num_operands field if you need the number of
operands.
+ */
+unsigned
  ir_expression::get_num_operands(ir_expression_operation op)
  {
 assert(op <= ir_last_opcode);

 if (op <= ir_last_unop)
return 1;

 if (op <= ir_last_binop)
return 2;

 if (op <= ir_last_triop)
return 3;

 if (op <= ir_last_quadop)
return 4;

-   assert(false);
+   assert("!could not calculate number of operands");


Assert(!"...")


Fixed. Thanks!

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


Re: [Mesa-dev] [PATCH] i965/drm: Inline brw_bo_references.

2017-07-30 Thread Jason Ekstrand

Rb


On July 30, 2017 4:08:48 PM Kenneth Graunke  wrote:


It's a single atomic add, so it makes sense to inline it.

Improves performance in Piglit's drawoverhead microbenchmark's
"DrawArrays ( 1 VBO, 0 UBO,  0) w/ no state change" subtest by
0.400922% +/- 0.310389% (n=350) on my i7-7700HQ.
---
 src/mesa/drivers/dri/i965/brw_bufmgr.c | 6 --
 src/mesa/drivers/dri/i965/brw_bufmgr.h | 7 ++-
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c 
b/src/mesa/drivers/dri/i965/brw_bufmgr.c

index 020d64849d9..f70365eba2a 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -196,12 +196,6 @@ bucket_for_size(struct brw_bufmgr *bufmgr, uint64_t size)
return NULL;
 }

-inline void
-brw_bo_reference(struct brw_bo *bo)
-{
-   p_atomic_inc(>refcount);
-}
-
 int
 brw_bo_busy(struct brw_bo *bo)
 {
diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.h 
b/src/mesa/drivers/dri/i965/brw_bufmgr.h

index 6a6051bb71c..15d37c04851 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.h
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.h
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include "util/u_atomic.h"
 #include "util/list.h"

 #if defined(__cplusplus)
@@ -188,7 +189,11 @@ struct brw_bo *brw_bo_alloc_tiled_2d(struct brw_bufmgr 
*bufmgr,

  unsigned flags);

 /** Takes a reference on a buffer object */
-void brw_bo_reference(struct brw_bo *bo);
+static inline void
+brw_bo_reference(struct brw_bo *bo)
+{
+   p_atomic_inc(>refcount);
+}

 /**
  * Releases a reference on a buffer object, freeing the data if
--
2.13.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] i965/drm: Inline brw_bo_references.

2017-07-30 Thread Kenneth Graunke
It's a single atomic add, so it makes sense to inline it.

Improves performance in Piglit's drawoverhead microbenchmark's
"DrawArrays ( 1 VBO, 0 UBO,  0) w/ no state change" subtest by
0.400922% +/- 0.310389% (n=350) on my i7-7700HQ.
---
 src/mesa/drivers/dri/i965/brw_bufmgr.c | 6 --
 src/mesa/drivers/dri/i965/brw_bufmgr.h | 7 ++-
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c 
b/src/mesa/drivers/dri/i965/brw_bufmgr.c
index 020d64849d9..f70365eba2a 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -196,12 +196,6 @@ bucket_for_size(struct brw_bufmgr *bufmgr, uint64_t size)
return NULL;
 }
 
-inline void
-brw_bo_reference(struct brw_bo *bo)
-{
-   p_atomic_inc(>refcount);
-}
-
 int
 brw_bo_busy(struct brw_bo *bo)
 {
diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.h 
b/src/mesa/drivers/dri/i965/brw_bufmgr.h
index 6a6051bb71c..15d37c04851 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.h
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.h
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include "util/u_atomic.h"
 #include "util/list.h"
 
 #if defined(__cplusplus)
@@ -188,7 +189,11 @@ struct brw_bo *brw_bo_alloc_tiled_2d(struct brw_bufmgr 
*bufmgr,
  unsigned flags);
 
 /** Takes a reference on a buffer object */
-void brw_bo_reference(struct brw_bo *bo);
+static inline void
+brw_bo_reference(struct brw_bo *bo)
+{
+   p_atomic_inc(>refcount);
+}
 
 /**
  * Releases a reference on a buffer object, freeing the data if
-- 
2.13.3

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


Re: [Mesa-dev] [PATCH 2/3] glsl: tidy up get_num_operands()

2017-07-30 Thread Ilia Mirkin
On Jul 30, 2017 5:38 PM, "Timothy Arceri"  wrote:

Also add a comment that this should only be used by the ir_reader
interface for testing purposes.
---
 src/compiler/glsl/ir.cpp |  8 ++--
 src/compiler/glsl/ir.h   | 14 +++---
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index d501e19c01..750582e40e 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -549,38 +549,42 @@ ir_expression::ir_expression(int op, ir_rvalue *op0,
ir_rvalue *op1,
case ir_triop_csel:
   this->type = op1->type;
   break;

default:
   assert(!"not reached: missing automatic type setup for
ir_expression");
   this->type = glsl_type::float_type;
}
 }

-unsigned int
+/**
+ * This is only here for ir_reader to used for testing purposes please use
+ * the precomputed num_operands field if you need the number of operands.
+ */
+unsigned
 ir_expression::get_num_operands(ir_expression_operation op)
 {
assert(op <= ir_last_opcode);

if (op <= ir_last_unop)
   return 1;

if (op <= ir_last_binop)
   return 2;

if (op <= ir_last_triop)
   return 3;

if (op <= ir_last_quadop)
   return 4;

-   assert(false);
+   assert("!could not calculate number of operands");


Assert(!"...")

return 0;
 }

 #include "ir_expression_operation_strings.h"

 const char*
 depth_layout_string(ir_depth_layout layout)
 {
switch(layout) {
case ir_depth_layout_none:  return "";
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index 377e03657d..70b5716965 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -1531,32 +1531,24 @@ public:
 * The "variable_context" hash table links ir_variable * to ir_constant
*
 * that represent the variables' values.  \c NULL represents an empty
 * context.
 *
 * If the expression cannot be constant folded, this method will return
 * \c NULL.
 */
virtual ir_constant *constant_expression_value(struct hash_table
*variable_context = NULL);

/**
-* Determine the number of operands used by an expression
+* This is only here for ir_reader to used for testing purposes please
use
+* the precomputed num_operands field if you need the number of
operands.
 */
-   static unsigned int get_num_operands(ir_expression_operation);
-
-   /**
-* Determine the number of operands used by an expression
-*/
-   unsigned int get_num_operands() const
-   {
-  return (this->operation == ir_quadop_vector)
-? this->type->vector_elements : get_num_operands(operation);
-   }
+   static unsigned get_num_operands(ir_expression_operation);

/**
 * Return whether the expression operates on vectors horizontally.
 */
bool is_horizontal() const
{
   return operation == ir_binop_all_equal ||
  operation == ir_binop_any_nequal ||
  operation == ir_binop_dot ||
  operation == ir_binop_vector_extract ||
--
2.13.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 1/3] glsl: calculate number of operands in an expression once

2017-07-30 Thread Timothy Arceri
Extra validation is added to ir_validate to make sure this is
always updated to the correct numer of operands, as passes like
lower_instructions modify the instructions directly rather then
generating a new one.
---
 src/compiler/glsl/glsl_to_nir.cpp  |  4 +--
 src/compiler/glsl/ir.cpp   | 20 +-
 src/compiler/glsl/ir.h | 13 +
 src/compiler/glsl/ir_builder_print_visitor.cpp |  8 +++---
 src/compiler/glsl/ir_clone.cpp |  2 +-
 src/compiler/glsl/ir_constant_expression.cpp   |  2 +-
 src/compiler/glsl/ir_equals.cpp|  2 +-
 src/compiler/glsl/ir_hv_accept.cpp |  2 +-
 src/compiler/glsl/ir_print_visitor.cpp |  2 +-
 src/compiler/glsl/ir_rvalue_visitor.cpp|  2 +-
 src/compiler/glsl/ir_validate.cpp  |  8 ++
 src/compiler/glsl/lower_instructions.cpp   | 32 ++
 src/compiler/glsl/lower_int64.cpp  |  4 +--
 src/compiler/glsl/lower_mat_op_to_vec.cpp  |  8 +++---
 src/compiler/glsl/lower_ubo_reference.cpp  |  2 +-
 .../glsl/lower_vec_index_to_cond_assign.cpp|  2 +-
 src/compiler/glsl/lower_vector.cpp |  2 +-
 src/compiler/glsl/opt_algebraic.cpp|  4 +--
 src/compiler/glsl/opt_constant_folding.cpp |  2 +-
 src/compiler/glsl/opt_tree_grafting.cpp|  2 +-
 src/mesa/program/ir_to_mesa.cpp|  4 +--
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |  6 ++--
 22 files changed, 102 insertions(+), 31 deletions(-)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
b/src/compiler/glsl/glsl_to_nir.cpp
index 4b3dbcff17..0bf82d126f 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -1480,25 +1480,25 @@ nir_visitor::visit(ir_expression *ir)
   }
 
   return;
}
 
default:
   break;
}
 
nir_ssa_def *srcs[4];
-   for (unsigned i = 0; i < ir->get_num_operands(); i++)
+   for (unsigned i = 0; i < ir->num_operands; i++)
   srcs[i] = evaluate_rvalue(ir->operands[i]);
 
glsl_base_type types[4];
-   for (unsigned i = 0; i < ir->get_num_operands(); i++)
+   for (unsigned i = 0; i < ir->num_operands; i++)
   if (supports_ints)
  types[i] = ir->operands[i]->type->base_type;
   else
  types[i] = GLSL_TYPE_FLOAT;
 
glsl_base_type out_type;
if (supports_ints)
   out_type = ir->type->base_type;
else
   out_type = GLSL_TYPE_FLOAT;
diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index 78889bd6d3..d501e19c01 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -196,38 +196,46 @@ ir_expression::ir_expression(int op, const struct 
glsl_type *type,
 ir_rvalue *op0, ir_rvalue *op1,
 ir_rvalue *op2, ir_rvalue *op3)
: ir_rvalue(ir_type_expression)
 {
this->type = type;
this->operation = ir_expression_operation(op);
this->operands[0] = op0;
this->operands[1] = op1;
this->operands[2] = op2;
this->operands[3] = op3;
+   init_num_operands();
+
 #ifndef NDEBUG
-   int num_operands = get_num_operands(this->operation);
for (int i = num_operands; i < 4; i++) {
   assert(this->operands[i] == NULL);
}
+
+   for (unsigned i = 0; i < num_operands; i++) {
+  assert(this->operands[i] != NULL);
+   }
 #endif
 }
 
 ir_expression::ir_expression(int op, ir_rvalue *op0)
: ir_rvalue(ir_type_expression)
 {
this->operation = ir_expression_operation(op);
this->operands[0] = op0;
this->operands[1] = NULL;
this->operands[2] = NULL;
this->operands[3] = NULL;
 
assert(op <= ir_last_unop);
+   init_num_operands();
+   assert(num_operands == 1);
+   assert(this->operands[0]);
 
switch (this->operation) {
case ir_unop_bit_not:
case ir_unop_logic_not:
case ir_unop_neg:
case ir_unop_abs:
case ir_unop_sign:
case ir_unop_rcp:
case ir_unop_rsq:
case ir_unop_sqrt:
@@ -418,20 +426,25 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
 ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
: ir_rvalue(ir_type_expression)
 {
this->operation = ir_expression_operation(op);
this->operands[0] = op0;
this->operands[1] = op1;
this->operands[2] = NULL;
this->operands[3] = NULL;
 
assert(op > ir_last_unop);
+   init_num_operands();
+   assert(num_operands == 2);
+   for (unsigned i = 0; i < num_operands; i++) {
+  assert(this->operands[i] != NULL);
+   }
 
switch (this->operation) {
case ir_binop_all_equal:
case ir_binop_any_nequal:
   this->type = glsl_type::bool_type;
   break;
 
case ir_binop_add:
case ir_binop_sub:
case ir_binop_min:
@@ -512,20 +525,25 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, 
ir_rvalue *op1,
  ir_rvalue *op2)
: 

[Mesa-dev] [PATCH 2/3] glsl: tidy up get_num_operands()

2017-07-30 Thread Timothy Arceri
Also add a comment that this should only be used by the ir_reader
interface for testing purposes.
---
 src/compiler/glsl/ir.cpp |  8 ++--
 src/compiler/glsl/ir.h   | 14 +++---
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index d501e19c01..750582e40e 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -549,38 +549,42 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, 
ir_rvalue *op1,
case ir_triop_csel:
   this->type = op1->type;
   break;
 
default:
   assert(!"not reached: missing automatic type setup for ir_expression");
   this->type = glsl_type::float_type;
}
 }
 
-unsigned int
+/**
+ * This is only here for ir_reader to used for testing purposes please use
+ * the precomputed num_operands field if you need the number of operands.
+ */
+unsigned
 ir_expression::get_num_operands(ir_expression_operation op)
 {
assert(op <= ir_last_opcode);
 
if (op <= ir_last_unop)
   return 1;
 
if (op <= ir_last_binop)
   return 2;
 
if (op <= ir_last_triop)
   return 3;
 
if (op <= ir_last_quadop)
   return 4;
 
-   assert(false);
+   assert("!could not calculate number of operands");
return 0;
 }
 
 #include "ir_expression_operation_strings.h"
 
 const char*
 depth_layout_string(ir_depth_layout layout)
 {
switch(layout) {
case ir_depth_layout_none:  return "";
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index 377e03657d..70b5716965 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -1531,32 +1531,24 @@ public:
 * The "variable_context" hash table links ir_variable * to ir_constant *
 * that represent the variables' values.  \c NULL represents an empty
 * context.
 *
 * If the expression cannot be constant folded, this method will return
 * \c NULL.
 */
virtual ir_constant *constant_expression_value(struct hash_table 
*variable_context = NULL);
 
/**
-* Determine the number of operands used by an expression
+* This is only here for ir_reader to used for testing purposes please use
+* the precomputed num_operands field if you need the number of operands.
 */
-   static unsigned int get_num_operands(ir_expression_operation);
-
-   /**
-* Determine the number of operands used by an expression
-*/
-   unsigned int get_num_operands() const
-   {
-  return (this->operation == ir_quadop_vector)
-? this->type->vector_elements : get_num_operands(operation);
-   }
+   static unsigned get_num_operands(ir_expression_operation);
 
/**
 * Return whether the expression operates on vectors horizontally.
 */
bool is_horizontal() const
{
   return operation == ir_binop_all_equal ||
  operation == ir_binop_any_nequal ||
  operation == ir_binop_dot ||
  operation == ir_binop_vector_extract ||
-- 
2.13.3

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


[Mesa-dev] [PATCH 3/3] glsl: stop copying struct and interface member names

2017-07-30 Thread Timothy Arceri
We are currently copying the name for each member dereference
but we can just share a single instance of the string provided
by the type.

This change also stops us recalculating the field index
repeatedly.
---
 src/compiler/glsl/ast_array_index.cpp  | 14 -
 src/compiler/glsl/glsl_to_nir.cpp  |  2 +-
 src/compiler/glsl/ir.cpp   |  8 ++
 src/compiler/glsl/ir.h |  4 +--
 src/compiler/glsl/ir_clone.cpp |  4 ++-
 src/compiler/glsl/ir_constant_expression.cpp   |  4 +--
 src/compiler/glsl/ir_print_visitor.cpp |  5 +++-
 src/compiler/glsl/linker.cpp   |  9 +-
 src/compiler/glsl/lower_buffer_access.cpp  |  6 ++--
 src/compiler/glsl/lower_named_interface_blocks.cpp |  3 +-
 src/compiler/glsl/opt_structure_splitting.cpp  | 10 ++-
 src/mesa/program/ir_to_mesa.cpp|  6 ++--
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 33 ++
 13 files changed, 49 insertions(+), 59 deletions(-)

diff --git a/src/compiler/glsl/ast_array_index.cpp 
b/src/compiler/glsl/ast_array_index.cpp
index f6b7a64a28..efddbed6ea 100644
--- a/src/compiler/glsl/ast_array_index.cpp
+++ b/src/compiler/glsl/ast_array_index.cpp
@@ -81,37 +81,37 @@ update_max_array_access(ir_rvalue *ir, int idx, YYLTYPE 
*loc,
  while (deref_array != NULL) {
 deref_array_prev = deref_array;
 deref_array = deref_array->array->as_dereference_array();
  }
  if (deref_array_prev != NULL)
 deref_var = deref_array_prev->array->as_dereference_variable();
   }
 
   if (deref_var != NULL) {
  if (deref_var->var->is_interface_instance()) {
-unsigned field_index =
-   deref_record->record->type->field_index(deref_record->field);
-assert(field_index < deref_var->var->get_interface_type()->length);
+unsigned field_idx = deref_record->field_idx;
+assert(field_idx < deref_var->var->get_interface_type()->length);
 
 int *const max_ifc_array_access =
deref_var->var->get_max_ifc_array_access();
 
 assert(max_ifc_array_access != NULL);
 
-if (idx > max_ifc_array_access[field_index]) {
-   max_ifc_array_access[field_index] = idx;
+if (idx > max_ifc_array_access[field_idx]) {
+   max_ifc_array_access[field_idx] = idx;
 
/* Check whether this access will, as a side effect, implicitly
 * cause the size of a built-in array to be too large.
 */
-   check_builtin_array_max_size(deref_record->field, idx+1, *loc,
-state);
+   const char *field_name =
+  deref_record->record->type->fields.structure[field_idx].name;
+   check_builtin_array_max_size(field_name, idx+1, *loc, state);
 }
  }
   }
}
 }
 
 
 static int
 get_implicit_array_size(struct _mesa_glsl_parse_state *state,
 ir_rvalue *array)
diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
b/src/compiler/glsl/glsl_to_nir.cpp
index 0bf82d126f..4cb153b5fc 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -2191,21 +2191,21 @@ nir_visitor::visit(ir_dereference_variable *ir)
nir_deref_var *deref = nir_deref_var_create(this->shader, var);
this->deref_head = deref;
this->deref_tail = >deref;
 }
 
 void
 nir_visitor::visit(ir_dereference_record *ir)
 {
ir->record->accept(this);
 
-   int field_index = this->deref_tail->type->field_index(ir->field);
+   int field_index = ir->field_idx;
assert(field_index >= 0);
 
nir_deref_struct *deref = nir_deref_struct_create(this->deref_tail, 
field_index);
deref->deref.type = ir->type;
this->deref_tail->child = >deref;
this->deref_tail = >deref;
 }
 
 void
 nir_visitor::visit(ir_dereference_array *ir)
diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index 750582e40e..4a0ceca9cc 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -1098,24 +1098,22 @@ ir_constant::get_array_element(unsigned i) const
 */
if (int(i) < 0)
   i = 0;
else if (i >= this->type->length)
   i = this->type->length - 1;
 
return array_elements[i];
 }
 
 ir_constant *
-ir_constant::get_record_field(const char *name)
+ir_constant::get_record_field(int idx)
 {
-   int idx = this->type->field_index(name);
-
if (idx < 0)
   return NULL;
 
if (this->components.is_empty())
   return NULL;
 
exec_node *node = this->components.get_head_raw();
for (int i = 0; i < idx; i++) {
   node = node->next;
 
@@ -1446,34 +1444,34 @@ ir_dereference_array::set_array(ir_rvalue *value)
 }
 
 
 ir_dereference_record::ir_dereference_record(ir_rvalue *value,
  

[Mesa-dev] [PATCH] radv: Don't underflow non-visible VRAM size.

2017-07-30 Thread Bas Nieuwenhuizen
n some APU situations the reported visible size can be larger than
VRAM size. This properly clamps the value.

Surprisingly both CTS and spec seem to allow a heap type with size 0,
so this seemed like the easiest option to me.

Signed-off-by: Bas Nieuwenhuizen 
Fixes: 4ae84efbc5c "radv: Use enum for memory heaps."
---
 src/amd/vulkan/radv_device.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 5244c157c35..b3041b9a47f 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -928,15 +928,17 @@ void radv_GetPhysicalDeviceMemoryProperties(
};
 
STATIC_ASSERT(RADV_MEM_HEAP_COUNT <= VK_MAX_MEMORY_HEAPS);
+   uint64_t visible_vram_size = MIN2(physical_device->rad_info.vram_size,
+ 
physical_device->rad_info.vram_vis_size);
 
pMemoryProperties->memoryHeapCount = RADV_MEM_HEAP_COUNT;
pMemoryProperties->memoryHeaps[RADV_MEM_HEAP_VRAM] = (VkMemoryHeap) {
.size = physical_device->rad_info.vram_size -
-   physical_device->rad_info.vram_vis_size,
+   visible_vram_size,
.flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
};
pMemoryProperties->memoryHeaps[RADV_MEM_HEAP_VRAM_CPU_ACCESS] = 
(VkMemoryHeap) {
-   .size = physical_device->rad_info.vram_vis_size,
+   .size = visible_vram_size,
.flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
};
pMemoryProperties->memoryHeaps[RADV_MEM_HEAP_GTT] = (VkMemoryHeap) {
-- 
2.13.3

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


Re: [Mesa-dev] [PATCH] nv50/ir: fix MUL ConstantFolding with saturation

2017-07-30 Thread Tobias Klausmann
Looks good to me!

Reviewed-by: Tobias Klausmann 


On 7/30/17 5:51 PM, Karol Herbst wrote:
> For mul(a, +-1) codegen could end up generating OP_MOV with a saturation flag
> set which we got simply ignored.
>
> Adding an assert for detecting more of such issues.
>
> Fixes wrongly rendered water in Hitman Absolution running under wine.
> Also a few shaders in Mad Max and Alien Isolation produce such MOVs.
>
> CC: 
> Signed-off-by: Karol Herbst 
> ---
>  src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp | 1 +
>  src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp  | 4 
>  2 files changed, 5 insertions(+)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp 
> b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp
> index 14c00bd187..58594f02c7 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp
> @@ -2006,6 +2006,7 @@ CodeEmitterNVC0::getSRegEncoding(const ValueRef& ref)
>  void
>  CodeEmitterNVC0::emitMOV(const Instruction *i)
>  {
> +   assert(!i->saturate);
> if (i->def(0).getFile() == FILE_PREDICATE) {
>if (i->src(0).getFile() == FILE_GPR) {
>   code[0] = 0xfc01c003;
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp 
> b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> index dac3e6f814..38fb542b74 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> @@ -1003,6 +1003,10 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue 
> , int s)
>   }
>   if (i->op != OP_CVT)
>  i->src(0).mod = 0;
> + if (i->op == OP_MOV && i->saturate) {
> +i->saturate = 0;
> +i->op = OP_SAT;
> + }
>   i->setSrc(1, NULL);
>} else
>if (!i->postFactor && (imm0.isInteger(2) || imm0.isInteger(-2))) {
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] nv50/ir: fix MUL ConstantFolding with saturation

2017-07-30 Thread Karol Herbst
For mul(a, +-1) codegen could end up generating OP_MOV with a saturation flag
set which we got simply ignored.

Adding an assert for detecting more of such issues.

Fixes wrongly rendered water in Hitman Absolution running under wine.
Also a few shaders in Mad Max and Alien Isolation produce such MOVs.

CC: 
Signed-off-by: Karol Herbst 
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp | 1 +
 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp  | 4 
 2 files changed, 5 insertions(+)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp
index 14c00bd187..58594f02c7 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp
@@ -2006,6 +2006,7 @@ CodeEmitterNVC0::getSRegEncoding(const ValueRef& ref)
 void
 CodeEmitterNVC0::emitMOV(const Instruction *i)
 {
+   assert(!i->saturate);
if (i->def(0).getFile() == FILE_PREDICATE) {
   if (i->src(0).getFile() == FILE_GPR) {
  code[0] = 0xfc01c003;
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index dac3e6f814..38fb542b74 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -1003,6 +1003,10 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue 
, int s)
  }
  if (i->op != OP_CVT)
 i->src(0).mod = 0;
+ if (i->op == OP_MOV && i->saturate) {
+i->saturate = 0;
+i->op = OP_SAT;
+ }
  i->setSrc(1, NULL);
   } else
   if (!i->postFactor && (imm0.isInteger(2) || imm0.isInteger(-2))) {
-- 
2.13.3

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


Re: [Mesa-dev] [PATCH v2] st/dri: add 32-bit RGBX/RGBA formats

2017-07-30 Thread Chih-Wei Huang
Hi Rob,
Sorry to bother you again.
This patch also breaks the srwast/llvmpipe on Android
since the red and blue are just swapped.
I guess nouveau has the same issue but
I'm waiting Mauro's confirmation.

Any comment?

-- 
Chih-Wei
Android-x86 project
http://www.android-x86.org
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2] st/dri: add 32-bit RGBX/RGBA formats

2017-07-30 Thread Chih-Wei Huang
2017-07-28 22:59 GMT+08:00 Marek Olšák :
> Hi,
>
> I've sent a request to revert this commit in 17.2. I'll keep it in
> master, but I'll add a fix not to expose the new formats for GLX.

I thought it doesn't break GLX according to
the commit message (investigation by Chad Versace).
Isn't it correct?

The issues I reported are all for Android.
Sorry if I didn't make it clear enough.

We still hope to use this patch to support
RGBA_ on Android since it gives
better app compatibility.
I guess some drivers (radeon/amdgpu/nouveau/swrast?)
need to be fixed to support RGBA_ better.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 101971] Mesa fails to build when Wayland and EGL support enabled due to missing C++ lib from mesautil

2017-07-30 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=101971

Mike Lothian  changed:

   What|Removed |Added

 CC||m...@fireburn.co.uk
 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #1 from Mike Lothian  ---


*** This bug has been marked as a duplicate of bug 11851 ***

-- 
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