Re: [Mesa-dev] [PATCH 1/3] gallium: add renderonly library

2016-12-07 Thread Alexandre Courbot
On 11/30/2016 10:44 PM, Christian Gmeiner wrote:
> This a very lightweight library to add basic support for
> renderonly GPUs. It does all the magic regarding in/exporting
> buffers etc. This library will likely break android support and
> hopefully will get replaced with a better solution based on gbm2.

Since we have no idea when said better solution will be available, and
the situation of render-only GPUs has been unsustainable for way too
long, I really hope a solution like this one can be merged in the meantime.

I have tried it after porting support for Tegra
(https://github.com/austriancoder/mesa/commit/2c7354701ee21ca28f69f5d7588f1d497553b4bf)
to this latest version. Here are a few issues I have met:

First, setting the tiling works indeed just fine if we are using an
ioctl for this. However my impression was that the preferred way of
doing it was through FB modifiers, and we started moving Tegra to this
scheme. Problem: the FB modifier is passed through a call to
drmModeAddFB2WithModifiers(), which is called by the client program, not
Mesa - which in this case leaves the program with the burden of figuring
out what the modifier should be. So with FB modifiers the problem is
still here.

Another issue I have seen is that GLX does not seem to work with this.
X/modesetting starts just fine, and GLamor also seems to initialize.
However glxinfo freezes on a xshmfence_await() call, and all GLX
programs fail as follow:

# glxgears
libGL error: MESA-LOADER: failed to retrieve device information
MESA-LOADER: failed to retrieve device information
MESA-LOADER: failed to retrieve device information
X Error of failed request:  BadAlloc (insufficient resources for operation)
  Major opcode of failed request:  149 ()
  Minor opcode of failed request:  2
  Serial number of failed request:  37
  Current serial number in output stream:  38

Not sure if you are having these issues with Vivante as well?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] gallivm: use getHostCPUFeatures on x86/llvm-4.0+.

2016-12-07 Thread Michel Dänzer
On 08/12/16 12:02 AM, Roland Scheidegger wrote:
> The bug in llvm has been fixed, can you confirm lp_test_format passes again?

Yep, it does, thanks!


-- 
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] Potentially EOL ilo gallium driver

2016-12-07 Thread Michel Dänzer
On 08/12/16 11:53 AM, Pierre-Loup A. Griffais wrote:
> On 12/07/2016 06:13 PM, Michel Dänzer wrote:
>> On 08/12/16 09:59 AM, Rob Clark wrote:
>>> +author again.. no idea why list keeps loosing extra cc's..
>>
>> Mailman removes addresses from Cc which are subscribed to the list and
>> have "Avoid duplicate copies of messages?" enabled in the list
>> Subscription Options.
> 
> As someone who gets email in a different folder, in a different color,
> and with a notification/sound effect when I get an email where I'm
> directly To'ed or Cc'ed, I would recommend disabling that setting :-)

So would I. :)

To clarify, this is a per-subscription setting, not a
mailing-list-global setting (though it's possible that it was enabled by
default for new mesa-dev subscriptions at some point, but that's not the
case now).

Also, at the risk of stating the obvious, it only affects the posts as
distributed by the list, not the original e-mail sent by the poster. So
affected e-mail addresses do receive the original e-mail directly via
Cc, just other list subscribers can't see that, so affected e-mail
addresses will most likely be missing from Cc on follow-ups.


-- 
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] Potentially EOL ilo gallium driver

2016-12-07 Thread Pierre-Loup A. Griffais



On 12/07/2016 06:13 PM, Michel Dänzer wrote:

On 08/12/16 09:59 AM, Rob Clark wrote:

+author again.. no idea why list keeps loosing extra cc's..


Mailman removes addresses from Cc which are subscribed to the list and
have "Avoid duplicate copies of messages?" enabled in the list
Subscription Options.


As someone who gets email in a different folder, in a different color, 
and with a notification/sound effect when I get an email where I'm 
directly To'ed or Cc'ed, I would recommend disabling that setting :-)





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


Re: [Mesa-dev] [PATCH] swr: [rasterizer core/memory] Finish R24_UNORM_X8_TYPELESS for AVX512

2016-12-07 Thread Cherniak, Bruce
Reviewed-by: Bruce Cherniak  

> On Dec 7, 2016, at 5:55 PM, Rowley, Timothy O  
> wrote:
> 
> This one-off specialization was missed.
> ---
> src/gallium/drivers/swr/rasterizer/core/backend.h  |  4 +-
> .../drivers/swr/rasterizer/memory/StoreTile.h  | 46 +++---
> 2 files changed, 24 insertions(+), 26 deletions(-)
> 
> diff --git a/src/gallium/drivers/swr/rasterizer/core/backend.h 
> b/src/gallium/drivers/swr/rasterizer/core/backend.h
> index 706b372..48cfce2 100644
> --- a/src/gallium/drivers/swr/rasterizer/core/backend.h
> +++ b/src/gallium/drivers/swr/rasterizer/core/backend.h
> @@ -463,7 +463,7 @@ inline void SetupBarycentricCoeffs(BarycentricCoeffs 
> *coeffs, const SWR_TRIANGLE
> 
> inline void SetupRenderBuffers(uint8_t *pColorBuffer[SWR_NUM_RENDERTARGETS], 
> uint8_t **pDepthBuffer, uint8_t **pStencilBuffer, uint32_t colorBufferCount, 
> RenderOutputBuffers )
> {
> -SWR_ASSERT(colorBufferCount <= SWR_NUM_RENDERTARGETS);
> +assert(colorBufferCount <= SWR_NUM_RENDERTARGETS);
> 
> if (pColorBuffer)
> {
> @@ -754,8 +754,6 @@ INLINE void OutputMerger(SWR_PS_CONTEXT , 
> uint8_t* ()[SWR_N
> INLINE void OutputMerger(SWR_PS_CONTEXT , uint8_t* 
> ()[SWR_NUM_RENDERTARGETS], uint32_t sample, const SWR_BLEND_STATE 
> *pBlendState,
> const PFN_BLEND_JIT_FUNC()[SWR_NUM_RENDERTARGETS], 
> simdscalar , simdscalar depthPassMask, const uint32_t NumRT, 
> bool useAlternateOffset)
> {
> -assert(sample == 0); // will need up upate Raster Tile Color Offsets to 
> support more than single sample here..
> -
> // type safety guaranteed from template instantiation in 
> BEChooser<>::GetFunc
> uint32_t rasterTileColorOffset = RasterTileColorOffset(sample);
> 
> diff --git a/src/gallium/drivers/swr/rasterizer/memory/StoreTile.h 
> b/src/gallium/drivers/swr/rasterizer/memory/StoreTile.h
> index 558f048..4fa6683 100644
> --- a/src/gallium/drivers/swr/rasterizer/memory/StoreTile.h
> +++ b/src/gallium/drivers/swr/rasterizer/memory/StoreTile.h
> @@ -545,38 +545,38 @@ struct ConvertPixelsSOAtoAOS R24_UNORM_X8_TYPELESS>
> INLINE static void Convert(const uint8_t* pSrc, uint8_t* 
> ()[NumDests])
> {
> #if USE_8x2_TILE_BACKEND
> -static const uint32_t MAX_RASTER_TILE_BYTES = 16 * 4; // 16 pixels * 
> 4 bytes per pixel
> +simd16scalar comp = _simd16_load_ps(reinterpret_cast *>(pSrc));
> 
> -OSALIGNSIMD16(uint8_t) soaTile[MAX_RASTER_TILE_BYTES];
> -OSALIGNSIMD16(uint8_t) aosTile[MAX_RASTER_TILE_BYTES];
> +// clamp
> +const simd16scalar zero = _simd16_setzero_ps();
> +const simd16scalar ones = _simd16_set1_ps(1.0f);
> 
> -// Convert from SrcFormat --> DstFormat
> -simd16vector src;
> -LoadSOA(pSrc, src);
> -StoreSOA(src, soaTile);
> +comp = _simd16_max_ps(comp, zero);
> +comp = _simd16_min_ps(comp, ones);
> 
> -// Convert from SOA --> AOS
> -FormatTraits::TransposeT::Transpose_16(soaTile, aosTile);
> -
> -// Store data into destination but don't overwrite the X8 bits
> -// Each 4-pixel row is 16-bytes
> +// normalize
> +comp = _simd16_mul_ps(comp, 
> _simd16_set1_ps(FormatTraits::fromFloat(0)));
> 
> -simdscalari loadlo = _simd_load_si(reinterpret_cast *>(aosTile));
> -simdscalari loadhi = _simd_load_si(reinterpret_cast *>(aosTile + sizeof(simdscalari)));
> +simd16scalari temp = _simd16_cvtps_epi32(comp);
> 
> -simdscalari templo = _simd_unpacklo_epi64(loadlo, loadhi);
> -simdscalari temphi = _simd_unpackhi_epi64(loadlo, loadhi);
> +// swizzle
> +temp = _simd16_permute_epi32(temp, _simd16_set_epi32(15, 14, 11, 10, 
> 13, 12, 9, 8, 7, 6, 3, 2, 5, 4, 1, 0));
> 
> +// merge/store data into destination but don't overwrite the X8 bits
> simdscalari destlo = _simd_loadu2_si(reinterpret_cast<__m128i 
> *>(ppDsts[1]), reinterpret_cast<__m128i *>(ppDsts[0]));
> simdscalari desthi = _simd_loadu2_si(reinterpret_cast<__m128i 
> *>(ppDsts[3]), reinterpret_cast<__m128i *>(ppDsts[2]));
> 
> -simdscalari mask = _simd_set1_epi32(0x00FF);
> +simd16scalari dest = _simd16_setzero_si();
> +
> +dest = _simd16_insert_si(dest, destlo, 0);
> +dest = _simd16_insert_si(dest, desthi, 1);
> +
> +simd16scalari mask = _simd16_set1_epi32(0x00FF);
> 
> -destlo = _simd_or_si(_simd_andnot_si(mask, destlo), 
> _simd_and_si(mask, templo));
> -desthi = _simd_or_si(_simd_andnot_si(mask, desthi), 
> _simd_and_si(mask, templo));
> +dest = _simd16_or_si(_simd16_andnot_si(mask, dest), 
> _simd16_and_si(mask, temp));
> 
> -_simd_storeu2_si(reinterpret_cast<__m128i *>(ppDsts[1]), 
> reinterpret_cast<__m128i *>(ppDsts[0]), destlo);
> -_simd_storeu2_si(reinterpret_cast<__m128i *>(ppDsts[3]), 
> reinterpret_cast<__m128i *>(ppDsts[2]), desthi);

Re: [Mesa-dev] [PATCH v2] swr: [rasterizer common/core/jitter] fetch support for GL_FIXED

2016-12-07 Thread Cherniak, Bruce
Reviewed-by: Bruce Cherniak  

> On Dec 7, 2016, at 7:16 PM, Tim Rowley  wrote:
> 
> v2: use fmul(1/65536) instead of fdiv(65535)
> ---
> .../drivers/swr/rasterizer/common/formats.cpp  | 104 ++---
> .../drivers/swr/rasterizer/common/formats.h|   7 +-
> .../drivers/swr/rasterizer/core/format_traits.h|  90 +-
> .../drivers/swr/rasterizer/jitter/fetch_jit.cpp|  12 +++
> src/gallium/drivers/swr/swr_screen.cpp |   9 ++
> 5 files changed, 188 insertions(+), 34 deletions(-)
> 
> diff --git a/src/gallium/drivers/swr/rasterizer/common/formats.cpp 
> b/src/gallium/drivers/swr/rasterizer/common/formats.cpp
> index b3a95f2..aba4c3f 100644
> --- a/src/gallium/drivers/swr/rasterizer/common/formats.cpp
> +++ b/src/gallium/drivers/swr/rasterizer/common/formats.cpp
> @@ -449,16 +449,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = {
> { 0.0f, 0.0f, 0.0f, 0.0f },
> 1, 1
> },
> -// padding (0x20)
> +// R32G32B32A32_SFIXED (0x20)
> {
> -nullptr,
> -{ SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, 
> SWR_TYPE_UNKNOWN },
> -{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },
> -0, 0, 0, false, false, false, false,
> -{ false, false, false, false },
> -{ 0.0f, 0.0f, 0.0f, 0.0f },
> -1, 1
> +"R32G32B32A32_SFIXED",
> +{ SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_SFIXED 
> },
> +{ 0, 0, 0, 0x3f80 }, // Defaults for missing components
> +{ 0, 1, 2, 3 }, // Swizzle
> +{ 32, 32, 32, 32 }, // Bits per component
> +128, // Bits per element
> +16, // Bytes per element
> +4, // Num components
> +false, // isSRGB
> +false, // isBC
> +false, // isSubsampled
> +false, // isLuminance
> +{ false, false, false, false }, // Is normalized?
> +{ 1.0f, 1.0f, 1.0f, 1.0f }, // To float scale factor
> +1, // bcWidth
> +1, // bcHeight
> },
> +
> // padding (0x21)
> {
> nullptr,
> @@ -979,16 +989,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = {
> { 0.0f, 0.0f, 0.0f, 0.0f },
> 1, 1
> },
> -// padding (0x50)
> +// R32G32B32_SFIXED (0x50)
> {
> -nullptr,
> -{ SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, 
> SWR_TYPE_UNKNOWN },
> -{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },
> -0, 0, 0, false, false, false, false,
> -{ false, false, false, false },
> -{ 0.0f, 0.0f, 0.0f, 0.0f },
> -1, 1
> +"R32G32B32_SFIXED",
> +{ SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, 
> SWR_TYPE_UNKNOWN },
> +{ 0, 0, 0, 0x3f80 }, // Defaults for missing components
> +{ 0, 1, 2, 0 }, // Swizzle
> +{ 32, 32, 32, 0 }, // Bits per component
> +96, // Bits per element
> +12, // Bytes per element
> +3, // Num components
> +false, // isSRGB
> +false, // isBC
> +false, // isSubsampled
> +false, // isLuminance
> +{ false, false, false, false }, // Is normalized?
> +{ 1.0f, 1.0f, 1.0f, 0 }, // To float scale factor
> +1, // bcWidth
> +1, // bcHeight
> },
> +
> // padding (0x51)
> {
> nullptr,
> @@ -1969,16 +1989,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = {
> { 0.0f, 0.0f, 0.0f, 0.0f },
> 1, 1
> },
> -// padding (0xA0)
> +// R32G32_SFIXED (0xA0)
> {
> -nullptr,
> -{ SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, 
> SWR_TYPE_UNKNOWN },
> -{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },
> -0, 0, 0, false, false, false, false,
> -{ false, false, false, false },
> -{ 0.0f, 0.0f, 0.0f, 0.0f },
> -1, 1
> +"R32G32_SFIXED",
> +{ SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_UNKNOWN, 
> SWR_TYPE_UNKNOWN },
> +{ 0, 0, 0, 0x3f80 }, // Defaults for missing components
> +{ 0, 1, 0, 0 }, // Swizzle
> +{ 32, 32, 0, 0 }, // Bits per component
> +64, // Bits per element
> +8, // Bytes per element
> +2, // Num components
> +false, // isSRGB
> +false, // isBC
> +false, // isSubsampled
> +false, // isLuminance
> +{ false, false, false, false }, // Is normalized?
> +{ 1.0f, 1.0f, 0, 0 }, // To float scale factor
> +1, // bcWidth
> +1, // bcHeight
> },
> +
> // padding (0xA1)
> {
> nullptr,
> @@ -5909,16 +5939,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = {
> 1, // bcHeight
> },
> 
> -// padding (0x1B2)
> +// R32_SFIXED (0x1B2)
> {
> -nullptr,
> -{ SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, 
> SWR_TYPE_UNKNOWN },
> -{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },
> -0, 0, 0, false, false, false, false,

[Mesa-dev] [PATCH] nir: update opt_dead_cf to merge some consecutive ifs

2016-12-07 Thread Timothy Arceri
This handles two cases. The first is where the second ifs
condition is a phi with constant srcs origination from the first if.
The second is where both ifs have the same condtion.

A limitation to merging is that currently this code will only merge
the ifs if there is only a single phi instruction in the block
between them. It may make sense to expand this in the future but
more research would be needed to see if its worth while.

All of the changes in shader-db are from the second use case. The
first use case is used to stop regression in the following patch
when switching to the NIR return lowering pass.

total instructions in shared programs: 8673389 -> 8673075 (-0.00%)
instructions in affected programs: 30364 -> 30050 (-1.03%)
helped: 90
HURT: 0

total cycles in shared programs: 73195178 -> 73258862 (0.09%)
cycles in affected programs: 642244 -> 705928 (9.92%)
helped: 6
HURT: 84
---
 src/compiler/nir/nir_opt_dead_cf.c | 146 -
 1 file changed, 142 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_opt_dead_cf.c 
b/src/compiler/nir/nir_opt_dead_cf.c
index 53c92ec..bc4d5b6 100644
--- a/src/compiler/nir/nir_opt_dead_cf.c
+++ b/src/compiler/nir/nir_opt_dead_cf.c
@@ -215,6 +215,48 @@ loop_is_dead(nir_loop *loop)
return true;
 }
 
+static void
+opt_merge_if(nir_if *dest_if, nir_if *src_if, bool dest_if_then,
+ bool src_if_then, nir_phi_instr *phi, nir_phi_src *phi_src)
+{
+   /* First rewrite the src for any instructions in the second if that use
+* the phi from the first if as a src.
+*/
+   nir_block *first_if_blk = src_if_then ? nir_if_first_then_block(src_if)
+ : nir_if_first_else_block(src_if);
+
+   nir_block *last_if_blk = src_if_then ? nir_if_last_then_block(src_if)
+: nir_if_last_else_block(src_if);
+
+   nir_foreach_use_safe(use_src, >dest.ssa) {
+  unsigned use_blk_idx = use_src->parent_instr->block->index;
+  if (first_if_blk->index <= use_blk_idx &&
+  last_if_blk->index >= use_blk_idx)
+ nir_instr_rewrite_src(use_src->parent_instr, use_src,
+   nir_src_for_ssa(phi_src->src.ssa));
+   }
+
+   nir_foreach_if_use_safe(use_src, >dest.ssa) {
+  unsigned use_blk_idx = use_src->parent_instr->block->index;
+  if (first_if_blk->index <= use_blk_idx &&
+  last_if_blk->index >= use_blk_idx)
+ nir_instr_rewrite_src(use_src->parent_instr, use_src,
+   nir_src_for_ssa(phi_src->src.ssa));
+   }
+
+   /* Now merge the if branch */
+   nir_block *dest_blk = dest_if_then ? nir_if_last_then_block(dest_if)
+  : nir_if_last_else_block(dest_if);
+
+   struct exec_list *list = src_if_then ? _if->then_list
+: _if->else_list;
+
+   nir_cf_list if_cf_list;
+   nir_cf_extract(_cf_list, nir_before_cf_list(list),
+  nir_after_cf_list(list));
+   nir_cf_reinsert(_cf_list, nir_after_block(dest_blk));
+}
+
 static bool
 dead_cf_block(nir_block *block)
 {
@@ -223,11 +265,105 @@ dead_cf_block(nir_block *block)
   nir_const_value *const_value =
  nir_src_as_const_value(following_if->condition);
 
-  if (!const_value)
- return false;
+  if (const_value) {
+ opt_constant_if(following_if, const_value->u32[0] != 0);
+ return true;
+  }
 
-  opt_constant_if(following_if, const_value->u32[0] != 0);
-  return true;
+  nir_block *next_blk = nir_cf_node_cf_tree_next(_if->cf_node);
+  if (next_blk && following_if->condition.is_ssa) {
+
+ nir_if *next_if = nir_block_get_following_if(next_blk);
+ if (next_if && next_if->condition.is_ssa &&
+ exec_list_length(_blk->instr_list) == 1) {
+
+nir_instr *blk_instr = nir_block_last_instr(next_blk);
+if (blk_instr->type == nir_instr_type_phi) {
+   nir_phi_instr *phi = nir_instr_as_phi(blk_instr);
+
+   if (blk_instr == next_if->condition.ssa->parent_instr) {
+  /* Here we merge two consecutive ifs where the second ifs
+   * condition is a phi with constant srcs originating from
+   * the first if e.g:
+   *
+   *   if ssa_1 {
+   *  block block_3:
+   *  vec1 32 ssa_2 = load_const (0x)
+   *  ...
+   *   } else {
+   *  block block_4:
+   *  vec1 32 ssa_3 = load_const (0x)
+   *  ...
+   *   }
+   *   vec1 32 ssa_4 = phi block_3: ssa_2, block_4: ssa_3
+   *   if ssa_4 {
+   *  ...
+   *   } else {
+   *  ...
+   *   }
+   */
+
+  unsigned i 

Re: [Mesa-dev] Potentially EOL ilo gallium driver

2016-12-07 Thread Michel Dänzer
On 08/12/16 09:59 AM, Rob Clark wrote:
> +author again.. no idea why list keeps loosing extra cc's..

Mailman removes addresses from Cc which are subscribed to the list and
have "Avoid duplicate copies of messages?" enabled in the list
Subscription Options.


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


[Mesa-dev] [Bug 99010] --disable-gallium-llvm no longer recognized

2016-12-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99010

--- Comment #14 from Tobias Droste  ---
Oops.

Fixes sent to mailing list:
https://lists.freedesktop.org/archives/mesa-dev/2016-December/137798.html

You now get a output like this:

llvm found:  yes
llvm-config: /llvm-config
llvm-version:4.0.0
llvm used:   yes

Gallium drivers: swrast
Gallium st:  mesa
Gallium llvm:no

with the important part being "Gallium llvm:no"

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


[Mesa-dev] [PATCH 2/6] configure.ac: Only set LLVM_LIBS if LLVM is used

2016-12-07 Thread Tobias Droste
This renames llvm_check_version_for to llvm_require_version and let it
set a variable to mark that LLVM will be used.

Use this to make a usefull configure output and to only check if the
libs are found in LLVM if it is actually used.

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

Signed-off-by: Tobias Droste 
---
 configure.ac | 33 -
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1499380c45..a209d87e62 100644
--- a/configure.ac
+++ b/configure.ac
@@ -998,13 +998,17 @@ llvm_set_environment_variables() {
 
 DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT 
-DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
 FOUND_LLVM=yes
+USE_LLVM=no
 else
 FOUND_LLVM=no
+USE_LLVM=no
 LLVM_VERSION_INT=0
 fi
 }
 
-llvm_check_version_for() {
+llvm_require_version() {
+USE_LLVM=yes
+
 if test "x$FOUND_LLVM" = xno; then
 AC_MSG_ERROR([LLVM $1 or newer is required for $2])
 return
@@ -1049,7 +1053,7 @@ radeon_llvm_check() {
 amdgpu_llvm_target_name='amdgpu'
 fi
 
-llvm_check_version_for $*
+llvm_require_version $*
 
 llvm_add_target $amdgpu_llvm_target_name $2
 
@@ -2176,7 +2180,7 @@ if test "x$enable_opencl" = xyes; then
AC_MSG_ERROR([Clover requires libelf])
 fi
 
-llvm_check_version_for $LLVM_REQUIRED_OPENCL "opencl"
+llvm_require_version $LLVM_REQUIRED_OPENCL "opencl"
 
 llvm_add_default_components "opencl"
 llvm_add_component "all-targets" "opencl"
@@ -2381,7 +2385,7 @@ dnl Gallium helper functions
 dnl
 gallium_require_llvm() {
 if test "x$enable_gallium_llvm" == "xyes"; then
-llvm_check_version_for $LLVM_REQUIRED_GALLIUM "gallium"
+llvm_require_version $LLVM_REQUIRED_GALLIUM "gallium"
 else
 AC_MSG_ERROR([--enable-gallium-llvm is required when building $1])
 fi
@@ -2511,7 +2515,7 @@ if test -n "$with_gallium_drivers"; then
 fi
 ;;
 xswr)
-llvm_check_version_for $LLVM_REQUIRED_SWR "swr"
+llvm_require_version $LLVM_REQUIRED_SWR "swr"
 gallium_require_llvm "swr"
 
 swr_require_cxx_feature_flags "C++11" "__cplusplus >= 201103L" \
@@ -2554,8 +2558,10 @@ if test -n "$with_gallium_drivers"; then
 fi
 
 if test "x$enable_gallium_llvm" == "xyes"; then
-llvm_check_version_for $LLVM_REQUIRED_GALLIUM "gallium"
+llvm_require_version $LLVM_REQUIRED_GALLIUM "gallium"
 llvm_add_default_components "gallium"
+
+HAVE_GALLIUM_LLVM=yes
 fi
 
 dnl Set LLVM_LIBS - This is done after the driver configuration so
@@ -2565,7 +2571,7 @@ dnl by calling llvm-config --libs 
${DRIVER_LLVM_COMPONENTS}, but
 dnl this was causing the same libraries to be appear multiple times
 dnl in LLVM_LIBS.
 
-if test "x$FOUND_LLVM" != xno; then
+if test "x$USE_LLVM" == xyes; then
 
 if ! $LLVM_CONFIG --libs ${LLVM_COMPONENTS} >/dev/null; then
AC_MSG_ERROR([Calling ${LLVM_CONFIG} failed])
@@ -2665,8 +2671,7 @@ AM_CONDITIONAL(NEED_RADEON_DRM_WINSYS, test 
"x$HAVE_GALLIUM_R300" = xyes -o \
 AM_CONDITIONAL(NEED_WINSYS_XLIB, test "x$enable_glx" = xgallium-xlib)
 AM_CONDITIONAL(NEED_RADEON_LLVM, test x$NEED_RADEON_LLVM = xyes)
 AM_CONDITIONAL(HAVE_GALLIUM_COMPUTE, test x$enable_opencl = xyes)
-AM_CONDITIONAL(HAVE_GALLIUM_LLVM, test "x$FOUND_LLVM" = xyes -a \
-   "x$enable_gallium_llvm" = xyes)
+AM_CONDITIONAL(HAVE_GALLIUM_LLVM, test "x$HAVE_GALLIUM_LLVM" = xyes)
 AM_CONDITIONAL(USE_VC4_SIMULATOR, test x$USE_VC4_SIMULATOR = xyes)
 if test "x$USE_VC4_SIMULATOR" = xyes -a "x$HAVE_GALLIUM_ILO" = xyes; then
 AC_MSG_ERROR([VC4 simulator on x86 replaces i965 driver build, so ilo must 
be disabled.])
@@ -2954,11 +2959,21 @@ if test "x$FOUND_LLVM" = xyes; then
 else
 echo "llvm found:  no"
 fi
+if test "x$USE_LLVM" = xyes; then
+echo "llvm used:   yes"
+else
+echo "llvm used:   no"
+fi
 
 echo ""
 if test -n "$with_gallium_drivers"; then
 echo "Gallium drivers: $gallium_drivers"
 echo "Gallium st:  $gallium_st"
+if test "x$HAVE_GALLIUM_LLVM" = xyes; then
+echo "Gallium llvm:yes"
+else
+echo "Gallium llvm:no"
+fi
 else
 echo "Gallium: no"
 fi
-- 
2.11.0

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


[Mesa-dev] [PATCH 3/6] configure.ac: Only define HAVE_LLVM if LLVM is used

2016-12-07 Thread Tobias Droste
Make sure that HAVE_LLVM compiler define is only set if LLVM is
actually used.

Signed-off-by: Tobias Droste 
---
 configure.ac | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index a209d87e62..7362ecdfaf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -996,7 +996,6 @@ llvm_set_environment_variables() {
 LLVM_VERSION_INT="${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR}"
 fi
 
-DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT 
-DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
 FOUND_LLVM=yes
 USE_LLVM=no
 else
@@ -2564,6 +2563,12 @@ if test "x$enable_gallium_llvm" == "xyes"; then
 HAVE_GALLIUM_LLVM=yes
 fi
 
+dnl Set HAVE_LLVM compiler define if LLVM is used.
+
+if test "x$USE_LLVM" == xyes; then
+DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT 
-DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
+fi
+
 dnl Set LLVM_LIBS - This is done after the driver configuration so
 dnl that drivers can add additional components to LLVM_COMPONENTS.
 dnl Previously, gallium drivers were updating LLVM_LIBS directly
-- 
2.11.0

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


[Mesa-dev] [PATCH 5/6] configure.ac: Make setting LLVM_LIBS a function

2016-12-07 Thread Tobias Droste
Make setting LLVM_LIBS a function, put it to the other LLVM related
functions and call it if LLVM is used.

Signed-off-by: Tobias Droste 
---
 configure.ac | 109 +--
 1 file changed, 54 insertions(+), 55 deletions(-)

diff --git a/configure.ac b/configure.ac
index d11f6cebc7..6e12ac8912 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1005,6 +1005,58 @@ llvm_set_environment_variables() {
 fi
 }
 
+dnl Set LLVM_LIBS - This is done after the driver configuration so
+dnl that drivers can add additional components to LLVM_COMPONENTS.
+dnl Previously, gallium drivers were updating LLVM_LIBS directly
+dnl by calling llvm-config --libs ${DRIVER_LLVM_COMPONENTS}, but
+dnl this was causing the same libraries to be appear multiple times
+dnl in LLVM_LIBS.
+llvm_set_llvm_libs() {
+if ! $LLVM_CONFIG --libs ${LLVM_COMPONENTS} >/dev/null; then
+   AC_MSG_ERROR([Calling ${LLVM_CONFIG} failed])
+fi
+LLVM_LIBS="`$LLVM_CONFIG --libs ${LLVM_COMPONENTS}`"
+
+dnl llvm-config may not give the right answer when llvm is a built as a
+dnl single shared library, so we must work the library name out for
+dnl ourselves.
+dnl (See https://llvm.org/bugs/show_bug.cgi?id=6823)
+if test "x$enable_llvm_shared_libs" = xyes; then
+dnl We can't use $LLVM_VERSION because it has 'svn' stripped out,
+LLVM_SO_NAME=LLVM-`$LLVM_CONFIG --version`
+AS_IF([test -f "$LLVM_LIBDIR/lib$LLVM_SO_NAME.$IMP_LIB_EXT"], 
[llvm_have_one_so=yes])
+
+if test "x$llvm_have_one_so" = xyes; then
+dnl LLVM was built using auto*, so there is only one shared object.
+LLVM_LIBS="-l$LLVM_SO_NAME"
+else
+dnl If LLVM was built with CMake, there will be one shared object 
per
+dnl component.
+AS_IF([test ! -f "$LLVM_LIBDIR/libLLVMTarget.$IMP_LIB_EXT"],
+[AC_MSG_ERROR([Could not find llvm shared libraries:
+   Please make sure you have built llvm with the --enable-shared option
+   and that your llvm libraries are installed in $LLVM_LIBDIR
+   If you have installed your llvm libraries to a different directory you
+   can use the --with-llvm-prefix= configure flag to specify this 
directory.
+   NOTE: Mesa is attempting to use llvm shared libraries by default.
+   If you do not want to build with llvm shared libraries and instead want 
to
+   use llvm static libraries then add --disable-llvm-shared-libs to your 
configure
+   invocation and rebuild.])])
+
+   dnl We don't need to update LLVM_LIBS in this case because the LLVM
+   dnl install uses a shared object for each component and we have
+   dnl already added all of these objects to LLVM_LIBS.
+fi
+else
+AC_MSG_WARN([Building mesa with statically linked LLVM may cause 
compilation issues])
+dnl We need to link to llvm system libs when using static libs
+dnl However, only llvm 3.5+ provides --system-libs
+if test $LLVM_VERSION_MAJOR -ge 4 -o $LLVM_VERSION_MAJOR -eq 3 -a 
$LLVM_VERSION_MINOR -ge 5; then
+LLVM_LIBS="$LLVM_LIBS `$LLVM_CONFIG --system-libs`"
+fi
+fi
+}
+
 llvm_require_version() {
 USE_LLVM=yes
 
@@ -2564,64 +2616,11 @@ if test "x$enable_gallium_llvm" == "xyes"; then
 DEFINES="${DEFINES} -DHAVE_GALLIUM_LLVM"
 fi
 
-dnl Set HAVE_LLVM compiler define if LLVM is used.
-
+dnl Define HAVE_LLVM and set LLVM_LIBS
 if test "x$USE_LLVM" == xyes; then
 DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT 
-DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
-fi
 
-dnl Set LLVM_LIBS - This is done after the driver configuration so
-dnl that drivers can add additional components to LLVM_COMPONENTS.
-dnl Previously, gallium drivers were updating LLVM_LIBS directly
-dnl by calling llvm-config --libs ${DRIVER_LLVM_COMPONENTS}, but
-dnl this was causing the same libraries to be appear multiple times
-dnl in LLVM_LIBS.
-
-if test "x$USE_LLVM" == xyes; then
-
-if ! $LLVM_CONFIG --libs ${LLVM_COMPONENTS} >/dev/null; then
-   AC_MSG_ERROR([Calling ${LLVM_CONFIG} failed])
-fi
-LLVM_LIBS="`$LLVM_CONFIG --libs ${LLVM_COMPONENTS}`"
-
-dnl llvm-config may not give the right answer when llvm is a built as a
-dnl single shared library, so we must work the library name out for
-dnl ourselves.
-dnl (See https://llvm.org/bugs/show_bug.cgi?id=6823)
-if test "x$enable_llvm_shared_libs" = xyes; then
-dnl We can't use $LLVM_VERSION because it has 'svn' stripped out,
-LLVM_SO_NAME=LLVM-`$LLVM_CONFIG --version`
-AS_IF([test -f "$LLVM_LIBDIR/lib$LLVM_SO_NAME.$IMP_LIB_EXT"], 
[llvm_have_one_so=yes])
-
-if test "x$llvm_have_one_so" = xyes; then
-dnl LLVM was built using auto*, so there is only one shared object.
-LLVM_LIBS="-l$LLVM_SO_NAME"
-else
-dnl If LLVM was built with CMake, 

[Mesa-dev] [PATCH 4/6] configure.ac: Set and use HAVE_GALLIUM_LLVM define

2016-12-07 Thread Tobias Droste
Gallium code used HAVE_LLVM to check if it needs to compile code for
LLVM in header and source files.

With the new logic HAVE_LLVM is always set. Use extra define to figure
out if LLVM is used.

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

Signed-off-by: Tobias Droste 
---
 configure.ac  |  1 +
 src/gallium/auxiliary/draw/draw_context.c | 14 +++---
 src/gallium/auxiliary/draw/draw_context.h |  2 +-
 src/gallium/auxiliary/draw/draw_pt.c  |  4 ++--
 src/gallium/auxiliary/draw/draw_vs.c  |  2 +-
 src/gallium/auxiliary/draw/draw_vs.h  |  2 +-
 6 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7362ecdfaf..d11f6cebc7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2561,6 +2561,7 @@ if test "x$enable_gallium_llvm" == "xyes"; then
 llvm_add_default_components "gallium"
 
 HAVE_GALLIUM_LLVM=yes
+DEFINES="${DEFINES} -DHAVE_GALLIUM_LLVM"
 fi
 
 dnl Set HAVE_LLVM compiler define if LLVM is used.
diff --git a/src/gallium/auxiliary/draw/draw_context.c 
b/src/gallium/auxiliary/draw/draw_context.c
index 56abcff5a2..f0dae1b1fe 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -45,7 +45,7 @@
 #include "draw_vs.h"
 #include "draw_gs.h"
 
-#if HAVE_LLVM
+#if HAVE_GALLIUM_LLVM
 #include "gallivm/lp_bld_init.h"
 #include "gallivm/lp_bld_limits.h"
 #include "draw_llvm.h"
@@ -78,7 +78,7 @@ draw_create_context(struct pipe_context *pipe, void *context,
/* we need correct cpu caps for disabling denorms in draw_vbo() */
util_cpu_detect();
 
-#if HAVE_LLVM
+#if HAVE_GALLIUM_LLVM
if (try_llvm && draw_get_option_use_llvm()) {
   draw->llvm = draw_llvm_create(draw, (LLVMContextRef)context);
}
@@ -112,7 +112,7 @@ draw_create(struct pipe_context *pipe)
 }
 
 
-#if HAVE_LLVM
+#if HAVE_GALLIUM_LLVM
 struct draw_context *
 draw_create_with_llvm_context(struct pipe_context *pipe,
   void *context)
@@ -221,7 +221,7 @@ void draw_destroy( struct draw_context *draw )
draw_pt_destroy( draw );
draw_vs_destroy( draw );
draw_gs_destroy( draw );
-#ifdef HAVE_LLVM
+#ifdef HAVE_GALLIUM_LLVM
if (draw->llvm)
   draw_llvm_destroy( draw->llvm );
 #endif
@@ -1003,7 +1003,7 @@ draw_set_samplers(struct draw_context *draw,
 
draw->num_samplers[shader_stage] = num;
 
-#ifdef HAVE_LLVM
+#ifdef HAVE_GALLIUM_LLVM
if (draw->llvm)
   draw_llvm_set_sampler_state(draw, shader_stage);
 #endif
@@ -1020,7 +1020,7 @@ draw_set_mapped_texture(struct draw_context *draw,
 uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
 uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS])
 {
-#ifdef HAVE_LLVM
+#ifdef HAVE_GALLIUM_LLVM
if (draw->llvm)
   draw_llvm_set_mapped_texture(draw,
shader_stage,
@@ -1057,7 +1057,7 @@ int
 draw_get_shader_param(unsigned shader, enum pipe_shader_cap param)
 {
 
-#ifdef HAVE_LLVM
+#ifdef HAVE_GALLIUM_LLVM
if (draw_get_option_use_llvm()) {
   switch(shader) {
   case PIPE_SHADER_VERTEX:
diff --git a/src/gallium/auxiliary/draw/draw_context.h 
b/src/gallium/auxiliary/draw/draw_context.h
index 145fc2ed46..782dec2dde 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -65,7 +65,7 @@ struct draw_so_target {
 
 struct draw_context *draw_create( struct pipe_context *pipe );
 
-#if HAVE_LLVM
+#if HAVE_GALLIUM_LLVM
 struct draw_context *draw_create_with_llvm_context(struct pipe_context *pipe,
void *context);
 #endif
diff --git a/src/gallium/auxiliary/draw/draw_pt.c 
b/src/gallium/auxiliary/draw/draw_pt.c
index 5a49acb64d..1be983f56a 100644
--- a/src/gallium/auxiliary/draw/draw_pt.c
+++ b/src/gallium/auxiliary/draw/draw_pt.c
@@ -191,7 +191,7 @@ boolean draw_pt_init( struct draw_context *draw )
if (!draw->pt.middle.general)
   return FALSE;
 
-#if HAVE_LLVM
+#if HAVE_GALLIUM_LLVM
if (draw->llvm)
   draw->pt.middle.llvm = draw_pt_fetch_pipeline_or_emit_llvm( draw );
 #endif
@@ -519,7 +519,7 @@ draw_vbo(struct draw_context *draw,
  draw->pt.vertex_element,
  draw->pt.nr_vertex_elements,
  info);
-#if HAVE_LLVM
+#if HAVE_GALLIUM_LLVM
if (!draw->llvm)
 #endif
{
diff --git a/src/gallium/auxiliary/draw/draw_vs.c 
b/src/gallium/auxiliary/draw/draw_vs.c
index 415c4fa949..e9966cf725 100644
--- a/src/gallium/auxiliary/draw/draw_vs.c
+++ b/src/gallium/auxiliary/draw/draw_vs.c
@@ -59,7 +59,7 @@ draw_create_vertex_shader(struct draw_context *draw,
   tgsi_dump(shader->tokens, 0);
}
 
-#if HAVE_LLVM
+#if HAVE_GALLIUM_LLVM
if (draw->pt.middle.llvm) {
   vs = draw_create_vs_llvm(draw, shader);
}
diff --git a/src/gallium/auxiliary/draw/draw_vs.h 

[Mesa-dev] [PATCH 6/6] configure.ac: Don't check LLVM version in gallium_require_llvm

2016-12-07 Thread Tobias Droste
This is actually not needed because the version is checked later.

Line 2609:
if test "x$enable_gallium_llvm" == "xyes"; then
llvm_require_version $LLVM_REQUIRED_GALLIUM "gallium"
llvm_add_default_components "gallium"

HAVE_GALLIUM_LLVM=xyes
DEFINES="${DEFINES} -DHAVE_GALLIUM_LLVM"
fi

Signed-off-by: Tobias Droste 
---
 configure.ac | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6e12ac8912..8457b388a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2435,9 +2435,7 @@ dnl
 dnl Gallium helper functions
 dnl
 gallium_require_llvm() {
-if test "x$enable_gallium_llvm" == "xyes"; then
-llvm_require_version $LLVM_REQUIRED_GALLIUM "gallium"
-else
+if test "x$enable_gallium_llvm" != "xyes"; then
 AC_MSG_ERROR([--enable-gallium-llvm is required when building $1])
 fi
 }
-- 
2.11.0

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


[Mesa-dev] [PATCH 1/6] configure.ac: Rename MESA_LLVM to FOUND_LLVM

2016-12-07 Thread Tobias Droste
this renames MESA_LLVM to FOUND_LLVM and updates the config.log report
to say if LLVM is found or not, to make clear that this does not mean
that it is used.

Signed-off-by: Tobias Droste 
---
 configure.ac | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/configure.ac b/configure.ac
index adca49d31e..1499380c45 100644
--- a/configure.ac
+++ b/configure.ac
@@ -997,15 +997,15 @@ llvm_set_environment_variables() {
 fi
 
 DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT 
-DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
-MESA_LLVM=1
+FOUND_LLVM=yes
 else
-MESA_LLVM=0
+FOUND_LLVM=no
 LLVM_VERSION_INT=0
 fi
 }
 
 llvm_check_version_for() {
-if test "x$MESA_LLVM" = x0; then
+if test "x$FOUND_LLVM" = xno; then
 AC_MSG_ERROR([LLVM $1 or newer is required for $2])
 return
 fi
@@ -1065,7 +1065,6 @@ radeon_llvm_check() {
 
 llvm_set_environment_variables
 
-AC_SUBST([MESA_LLVM])
 AC_SUBST([LLVM_BINDIR])
 AC_SUBST([LLVM_CFLAGS])
 AC_SUBST([LLVM_CPPFLAGS])
@@ -2507,7 +2506,7 @@ if test -n "$with_gallium_drivers"; then
 ;;
 xswrast)
 HAVE_GALLIUM_SOFTPIPE=yes
-if test "x$MESA_LLVM" = x1 && test "x$enable_gallium_llvm" == 
"xyes";  then
+if test "x$FOUND_LLVM" = xyes && test "x$enable_gallium_llvm" == 
"xyes";  then
 HAVE_GALLIUM_LLVMPIPE=yes
 fi
 ;;
@@ -2566,7 +2565,7 @@ dnl by calling llvm-config --libs 
${DRIVER_LLVM_COMPONENTS}, but
 dnl this was causing the same libraries to be appear multiple times
 dnl in LLVM_LIBS.
 
-if test "x$MESA_LLVM" != x0; then
+if test "x$FOUND_LLVM" != xno; then
 
 if ! $LLVM_CONFIG --libs ${LLVM_COMPONENTS} >/dev/null; then
AC_MSG_ERROR([Calling ${LLVM_CONFIG} failed])
@@ -2666,7 +2665,7 @@ AM_CONDITIONAL(NEED_RADEON_DRM_WINSYS, test 
"x$HAVE_GALLIUM_R300" = xyes -o \
 AM_CONDITIONAL(NEED_WINSYS_XLIB, test "x$enable_glx" = xgallium-xlib)
 AM_CONDITIONAL(NEED_RADEON_LLVM, test x$NEED_RADEON_LLVM = xyes)
 AM_CONDITIONAL(HAVE_GALLIUM_COMPUTE, test x$enable_opencl = xyes)
-AM_CONDITIONAL(HAVE_GALLIUM_LLVM, test "x$MESA_LLVM" = x1 -a \
+AM_CONDITIONAL(HAVE_GALLIUM_LLVM, test "x$FOUND_LLVM" = xyes -a \
"x$enable_gallium_llvm" = xyes)
 AM_CONDITIONAL(USE_VC4_SIMULATOR, test x$USE_VC4_SIMULATOR = xyes)
 if test "x$USE_VC4_SIMULATOR" = xyes -a "x$HAVE_GALLIUM_ILO" = xyes; then
@@ -2948,12 +2947,12 @@ else
 fi
 
 echo ""
-if test "x$MESA_LLVM" = x1; then
-echo "llvm:yes"
+if test "x$FOUND_LLVM" = xyes; then
+echo "llvm found:  yes"
 echo "llvm-config: $LLVM_CONFIG"
 echo "llvm-version:$LLVM_VERSION"
 else
-echo "llvm:no"
+echo "llvm found:  no"
 fi
 
 echo ""
@@ -3002,7 +3001,7 @@ echo "CFLAGS:  $cflags"
 echo "CXXFLAGS:$cxxflags"
 echo "Macros:  $defines"
 echo ""
-if test "x$MESA_LLVM" = x1; then
+if test "x$FOUND_LLVM" = xyes; then
 echo "LLVM_CFLAGS: $LLVM_CFLAGS"
 echo "LLVM_CXXFLAGS:   $LLVM_CXXFLAGS"
 echo "LLVM_CPPFLAGS:   $LLVM_CPPFLAGS"
-- 
2.11.0

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


[Mesa-dev] [PATCH 0/6] configure.ac: Bug fixes and related optimizations

2016-12-07 Thread Tobias Droste
Patches 1 to 4 (hopefully) fix 
https://bugs.freedesktop.org/show_bug.cgi?id=99010.

Patch 5 and 6 are cosmetic changes.

I build and run tested this with radeonsi, radv and llvmpipe and build tested 
with softpipe.

@Emil:
Please test and push if everything is ok.

Tobias Droste (6):
  configure.ac: Rename MESA_LLVM to FOUND_LLVM
  configure.ac: Only set LLVM_LIBS if LLVM is used
  configure.ac: Only define HAVE_LLVM if LLVM is used
  configure.ac: Set and use HAVE_GALLIUM_LLVM define
  configure.ac: Make setting LLVM_LIBS a function
  configure.ac: Don't check LLVM version in gallium_require_llvm

 configure.ac  | 159 +-
 src/gallium/auxiliary/draw/draw_context.c |  14 +--
 src/gallium/auxiliary/draw/draw_context.h |   2 +-
 src/gallium/auxiliary/draw/draw_pt.c  |   4 +-
 src/gallium/auxiliary/draw/draw_vs.c  |   2 +-
 src/gallium/auxiliary/draw/draw_vs.h  |   2 +-
 6 files changed, 100 insertions(+), 83 deletions(-)

-- 
2.11.0

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


Re: [Mesa-dev] Potentially EOL ilo gallium driver

2016-12-07 Thread Chia-I Wu
Hi all,

Sorry for the slow response.  I think it is fine to drop the driver :(

Not because the driver is currently unmaintained, which is very true
and is a very good reason, but that there is now a Intel Vulkan
driver.  Vulkan is somewhat as low-level as Gallium is (or even
lower-level).  The driver has most things I like to see as well (low
CPU overhead, minimal/predictable heap allocation, generated register
descriptions, etc.).  Sorry for the confusions and burdens it bring to
others, and thanks to the few individuals/groups who find it useful
for their needs at various times.


On Thu, Dec 8, 2016 at 8:33 AM, Edward O'Callaghan
 wrote:
>
>
> On 12/08/2016 11:28 AM, Roland Scheidegger wrote:
>> I haven't seen the driver author's opinion on this yet, so it's probably
>> fair to give him some more time to answer. It's not like this is really
>> urgent...
>
> Absolutely!
>
>>
>> Roland
>>
>> Am 08.12.2016 um 01:11 schrieb Edward O'Callaghan:
>>> Hi all,
>>>
>>> So I'll get right to the crux of this; In summary the consensus would
>>> then be to drop ilo?
>>>
>>> If so, I am not sure of this communities procedure? However, if it helps
>>> the patch is here:
>>> https://cgit.freedesktop.org/~funfunctor/mesa/log/?h=eol-ilo
>>>
>>> Kind Regards,
>>> Edward.
>>>
>>> On 12/07/2016 07:08 AM, Ilia Mirkin wrote:
 On Tue, Dec 6, 2016 at 3:00 PM, Rob Clark  wrote:
> On Tue, Dec 6, 2016 at 2:11 PM, Jason Ekstrand  
> wrote:
>> On Tue, Dec 6, 2016 at 8:39 AM, Rob Clark  wrote:
>>>
>>> On Tue, Dec 6, 2016 at 8:42 AM, Emil Velikov 
>>> wrote:
 On 6 December 2016 at 03:16, Edward O'Callaghan
  wrote:
> This patch is to potentially remove ourself from the maintaince
> burden of the ilo driver that appears to now be essentially
> unmaintained?
>
> I am not sure of our policy here or if there are too many
> users so this patch is really only to gauge a response of
> how folks feel?
>
 Surely you want to CC the core/sole developer of the driver when
 considering its removal.
 Maybe mailman was "nice" and hid his email in the header ;-)

 Either way adding Chia-I Wu to the list.

 -Emil
 P.S. Not sure/sold how much of an actual burden the driver is, yet I
 don't make serious gallium infra changes.
>>>
>>> really hasn't been a problem for me..
>>>
>>> That said, it would be nice if someday someone wired this up to use
>>> glsl_to_nir path in gallium and re-used i965's nir backend.  I think
>>> that would make ilo somewhat more interesting..
>>
>>
>> We had a bit of a chat about this on IRC and what I told Ilia there was 
>> that
>> the more interesting thing to do, if someone really wanted to do Intel on
>> gallium, would probably be to build a new driver based on ISL, blorp, the
>> i965 compiler, NIR, and genxml.  We've made a pretty good driver-building
>> toolbox.  Having an almost unmaintained driver that has it's own 
>> hand-rolled
>> and inferrior compiler, surface layout, etc. isn't doing much good.
>>
>
> yeah, reusing the other bits would be nice too, and hopefully would be
> the long term goal if someone where to spend time on this.. I guess
> I'd prefer a more incremental approach of converting parts one by one
> if I were doing it myself.  It's kind of a moot point either way until
> someone has time/motivation to spend on it.
>
> But I've no real objection to dropping ilo until then if others feel
> strongly.. it's still there in git history so it can be resurrected if
> someone wants to convert to reuse other i965 bits incrementally rather
> than starting from scratch.

 As mentioned on IRC, I think the real use-case that ilo could cover
 that i965/anv can't (easily) handle is acting as a gallium-nine
 backend. (I know someone's working on DX9 over vulkan, but that's
 hardly ready, and will never be available on gen6.)

 However at this time, it's not sufficiently functional to handle
 gallium-nine, so I don't see any serious downside to dropping it.

   -ilia

>>>
>>>
>>>
>>> ___
>>> 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 mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] cso: don't release sampler states that are bound

2016-12-07 Thread Michel Dänzer
On 07/12/16 07:16 PM, Nicolai Hähnle wrote:
> On 07.12.2016 08:50, Michel Dänzer wrote:
>> On 06/12/16 10:24 PM, Marek Olšák wrote:
>>> On Mon, Dec 5, 2016 at 10:05 AM, Michel Dänzer 
>>> wrote:
 On 03/12/16 05:38 AM, Marek Olšák wrote:
> From: Marek Olšák 
>
> This fixes random radeonsi GPU hangs in Batman Arkham: Origins
> (Wine) and
> probably many other games too.
>
> cso_cache deletes sampler states when the cache size is too big and
> doesn't
> check which sampler states are bound, causing use-after-free in
> drivers.
> Because of that, radeonsi uploaded garbage sampler states and the
> hardware
> went bananas. Other drivers may have experienced similar issues.
>
> Cc: 13.0 12.0 
> ---
>  src/gallium/auxiliary/cso_cache/cso_cache.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.c
> b/src/gallium/auxiliary/cso_cache/cso_cache.c
> index b240c93..1f3be4b 100644
> --- a/src/gallium/auxiliary/cso_cache/cso_cache.c
> +++ b/src/gallium/auxiliary/cso_cache/cso_cache.c
> @@ -181,21 +181,23 @@ static inline void sanitize_cb(struct
> cso_hash *hash, enum cso_cache_type type,
>--to_remove;
> }
>  }
>
>  struct cso_hash_iter
>  cso_insert_state(struct cso_cache *sc,
>   unsigned hash_key, enum cso_cache_type type,
>   void *state)
>  {
> struct cso_hash *hash = _cso_hash_for_type(sc, type);
> -   sanitize_hash(sc, hash, type, sc->max_size);
> +
> +   if (type != CSO_SAMPLER)
> +  sanitize_hash(sc, hash, type, sc->max_size);
>
> return cso_hash_insert(hash, hash_key, state);
>  }
>
>  struct cso_hash_iter
>  cso_find_state(struct cso_cache *sc,
> unsigned hash_key, enum cso_cache_type type)
>  {
> struct cso_hash *hash = _cso_hash_for_type(sc, type);
>
>

 If I understand correctly, this means that the maximum cache size
 effectively isn't enforced for sampler states? Wouldn't it be better
 instead to add code which prevents currently bound states from being
 deleted from here?
>>>
>>> Not in this patch. Maybe later and if CPU profiling results show that
>>> it matters.
>>>
>>> Currently, if the cache size is exceeded, the GPU usually hangs. If
>>> pruning the cache was important, most apps would hang.
>>>
>>> Thus, I'd like to push this as-is.
>>
>> Fair enough, but this will require some follow-up work:
>>
>> Why are sampler states singled out? The same problem can at least
>> theoretically happen with other CSOs as well, right?
> 
> The other CSOs only have single bind points. So with other CSOs, what
> happens is that:
> 
> 1. State tracker wants to bind some state, creates the CSO.
> 2. cso_cache gets cleaned out; this might delete the currently bound CSO.
> 3. Currently bound CSO gets immediately overwritten with the new state
> anyway.
> 
> Samplers are different because there are many bind points within a
> single context.
> 
> You're right though that the sounder approach would be to check all CSOs
> against current bind points during cache cleanup, just in case a driver
> does something with the old state on unbind.

That does seem rather unlikely though. Thanks for clarifying this.


>> P.S. The bug has been there forever, so I don't see the justification
>> for bypassing the normal stable branch process.
> 
> And we've had mysterious hang bug reports forever as well. I wouldn't be
> surprised if a large number or even all of them could be traced back to
> this issue.

If I had JPY 100 for every time I had such hope for a fix... :) I really
hope this is the one, but experience suggests it's more likely that
there are lots of different issues causing GPU hangs.


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


[Mesa-dev] [PATCH v2] swr: [rasterizer common/core/jitter] fetch support for GL_FIXED

2016-12-07 Thread Tim Rowley
v2: use fmul(1/65536) instead of fdiv(65535)
---
 .../drivers/swr/rasterizer/common/formats.cpp  | 104 ++---
 .../drivers/swr/rasterizer/common/formats.h|   7 +-
 .../drivers/swr/rasterizer/core/format_traits.h|  90 +-
 .../drivers/swr/rasterizer/jitter/fetch_jit.cpp|  12 +++
 src/gallium/drivers/swr/swr_screen.cpp |   9 ++
 5 files changed, 188 insertions(+), 34 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/common/formats.cpp 
b/src/gallium/drivers/swr/rasterizer/common/formats.cpp
index b3a95f2..aba4c3f 100644
--- a/src/gallium/drivers/swr/rasterizer/common/formats.cpp
+++ b/src/gallium/drivers/swr/rasterizer/common/formats.cpp
@@ -449,16 +449,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = {
 { 0.0f, 0.0f, 0.0f, 0.0f },
 1, 1
 },
-// padding (0x20)
+// R32G32B32A32_SFIXED (0x20)
 {
-nullptr,
-{ SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, 
SWR_TYPE_UNKNOWN },
-{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },
-0, 0, 0, false, false, false, false,
-{ false, false, false, false },
-{ 0.0f, 0.0f, 0.0f, 0.0f },
-1, 1
+"R32G32B32A32_SFIXED",
+{ SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_SFIXED },
+{ 0, 0, 0, 0x3f80 }, // Defaults for missing components
+{ 0, 1, 2, 3 }, // Swizzle
+{ 32, 32, 32, 32 }, // Bits per component
+128, // Bits per element
+16, // Bytes per element
+4, // Num components
+false, // isSRGB
+false, // isBC
+false, // isSubsampled
+false, // isLuminance
+{ false, false, false, false }, // Is normalized?
+{ 1.0f, 1.0f, 1.0f, 1.0f }, // To float scale factor
+1, // bcWidth
+1, // bcHeight
 },
+
 // padding (0x21)
 {
 nullptr,
@@ -979,16 +989,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = {
 { 0.0f, 0.0f, 0.0f, 0.0f },
 1, 1
 },
-// padding (0x50)
+// R32G32B32_SFIXED (0x50)
 {
-nullptr,
-{ SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, 
SWR_TYPE_UNKNOWN },
-{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },
-0, 0, 0, false, false, false, false,
-{ false, false, false, false },
-{ 0.0f, 0.0f, 0.0f, 0.0f },
-1, 1
+"R32G32B32_SFIXED",
+{ SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_UNKNOWN 
},
+{ 0, 0, 0, 0x3f80 }, // Defaults for missing components
+{ 0, 1, 2, 0 }, // Swizzle
+{ 32, 32, 32, 0 }, // Bits per component
+96, // Bits per element
+12, // Bytes per element
+3, // Num components
+false, // isSRGB
+false, // isBC
+false, // isSubsampled
+false, // isLuminance
+{ false, false, false, false }, // Is normalized?
+{ 1.0f, 1.0f, 1.0f, 0 }, // To float scale factor
+1, // bcWidth
+1, // bcHeight
 },
+
 // padding (0x51)
 {
 nullptr,
@@ -1969,16 +1989,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = {
 { 0.0f, 0.0f, 0.0f, 0.0f },
 1, 1
 },
-// padding (0xA0)
+// R32G32_SFIXED (0xA0)
 {
-nullptr,
-{ SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, 
SWR_TYPE_UNKNOWN },
-{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },
-0, 0, 0, false, false, false, false,
-{ false, false, false, false },
-{ 0.0f, 0.0f, 0.0f, 0.0f },
-1, 1
+"R32G32_SFIXED",
+{ SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN 
},
+{ 0, 0, 0, 0x3f80 }, // Defaults for missing components
+{ 0, 1, 0, 0 }, // Swizzle
+{ 32, 32, 0, 0 }, // Bits per component
+64, // Bits per element
+8, // Bytes per element
+2, // Num components
+false, // isSRGB
+false, // isBC
+false, // isSubsampled
+false, // isLuminance
+{ false, false, false, false }, // Is normalized?
+{ 1.0f, 1.0f, 0, 0 }, // To float scale factor
+1, // bcWidth
+1, // bcHeight
 },
+
 // padding (0xA1)
 {
 nullptr,
@@ -5909,16 +5939,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = {
 1, // bcHeight
 },
 
-// padding (0x1B2)
+// R32_SFIXED (0x1B2)
 {
-nullptr,
-{ SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, 
SWR_TYPE_UNKNOWN },
-{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },
-0, 0, 0, false, false, false, false,
-{ false, false, false, false },
-{ 0.0f, 0.0f, 0.0f, 0.0f },
-1, 1
+"R32_SFIXED",
+{ SWR_TYPE_SFIXED, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, 
SWR_TYPE_UNKNOWN },
+{ 0, 0, 0, 0x3f80 }, // Defaults for missing components
+{ 0, 0, 0, 0 }, // Swizzle
+{ 32, 0, 0, 0 }, // Bits per component
+32, // Bits per 

Re: [Mesa-dev] [PATCH] radv/ac: no need to pass nir to the post outputs handling

2016-12-07 Thread Edward O'Callaghan
Reviewed-by: Edward O'Callaghan 

On 12/08/2016 11:55 AM, Dave Airlie wrote:
> From: Dave Airlie 
> 
> We don't use the nir shader in here at all.
> 
> Signed-off-by: Dave Airlie 
> ---
>  src/amd/common/ac_nir_to_llvm.c | 15 ++-
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index bb52e8f..f5f78a3 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -4369,8 +4369,7 @@ si_llvm_init_export_args(struct nir_to_llvm_context 
> *ctx,
>  }
>  
>  static void
> -handle_vs_outputs_post(struct nir_to_llvm_context *ctx,
> -   struct nir_shader *nir)
> +handle_vs_outputs_post(struct nir_to_llvm_context *ctx)
>  {
>   uint32_t param_count = 0;
>   unsigned target;
> @@ -4572,8 +4571,7 @@ si_export_mrt_z(struct nir_to_llvm_context *ctx,
>  }
>  
>  static void
> -handle_fs_outputs_post(struct nir_to_llvm_context *ctx,
> -struct nir_shader *nir)
> +handle_fs_outputs_post(struct nir_to_llvm_context *ctx)
>  {
>   unsigned index = 0;
>   LLVMValueRef depth = NULL, stencil = NULL, samplemask = NULL;
> @@ -4615,15 +4613,14 @@ handle_fs_outputs_post(struct nir_to_llvm_context 
> *ctx,
>  }
>  
>  static void
> -handle_shader_outputs_post(struct nir_to_llvm_context *ctx,
> -struct nir_shader *nir)
> +handle_shader_outputs_post(struct nir_to_llvm_context *ctx)
>  {
>   switch (ctx->stage) {
>   case MESA_SHADER_VERTEX:
> - handle_vs_outputs_post(ctx, nir);
> + handle_vs_outputs_post(ctx);
>   break;
>   case MESA_SHADER_FRAGMENT:
> - handle_fs_outputs_post(ctx, nir);
> + handle_fs_outputs_post(ctx);
>   break;
>   default:
>   break;
> @@ -4741,7 +4738,7 @@ LLVMModuleRef 
> ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
>   visit_cf_list(, >impl->body);
>   phi_post_pass();
>  
> - handle_shader_outputs_post(, nir);
> + handle_shader_outputs_post();
>   LLVMBuildRetVoid(ctx.builder);
>  
>   ac_llvm_finalize_module();
> 



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


Re: [Mesa-dev] Potentially EOL ilo gallium driver

2016-12-07 Thread Rob Clark
+author again.. no idea why list keeps loosing extra cc's.. it is
kinda annoying..

BR,
-R

On Wed, Dec 7, 2016 at 7:28 PM, Roland Scheidegger  wrote:
> I haven't seen the driver author's opinion on this yet, so it's probably
> fair to give him some more time to answer. It's not like this is really
> urgent...
>
> Roland
>
> Am 08.12.2016 um 01:11 schrieb Edward O'Callaghan:
>> Hi all,
>>
>> So I'll get right to the crux of this; In summary the consensus would
>> then be to drop ilo?
>>
>> If so, I am not sure of this communities procedure? However, if it helps
>> the patch is here:
>> https://cgit.freedesktop.org/~funfunctor/mesa/log/?h=eol-ilo
>>
>> Kind Regards,
>> Edward.
>>
>> On 12/07/2016 07:08 AM, Ilia Mirkin wrote:
>>> On Tue, Dec 6, 2016 at 3:00 PM, Rob Clark  wrote:
 On Tue, Dec 6, 2016 at 2:11 PM, Jason Ekstrand  
 wrote:
> On Tue, Dec 6, 2016 at 8:39 AM, Rob Clark  wrote:
>>
>> On Tue, Dec 6, 2016 at 8:42 AM, Emil Velikov 
>> wrote:
>>> On 6 December 2016 at 03:16, Edward O'Callaghan
>>>  wrote:
 This patch is to potentially remove ourself from the maintaince
 burden of the ilo driver that appears to now be essentially
 unmaintained?

 I am not sure of our policy here or if there are too many
 users so this patch is really only to gauge a response of
 how folks feel?

>>> Surely you want to CC the core/sole developer of the driver when
>>> considering its removal.
>>> Maybe mailman was "nice" and hid his email in the header ;-)
>>>
>>> Either way adding Chia-I Wu to the list.
>>>
>>> -Emil
>>> P.S. Not sure/sold how much of an actual burden the driver is, yet I
>>> don't make serious gallium infra changes.
>>
>> really hasn't been a problem for me..
>>
>> That said, it would be nice if someday someone wired this up to use
>> glsl_to_nir path in gallium and re-used i965's nir backend.  I think
>> that would make ilo somewhat more interesting..
>
>
> We had a bit of a chat about this on IRC and what I told Ilia there was 
> that
> the more interesting thing to do, if someone really wanted to do Intel on
> gallium, would probably be to build a new driver based on ISL, blorp, the
> i965 compiler, NIR, and genxml.  We've made a pretty good driver-building
> toolbox.  Having an almost unmaintained driver that has it's own 
> hand-rolled
> and inferrior compiler, surface layout, etc. isn't doing much good.
>

 yeah, reusing the other bits would be nice too, and hopefully would be
 the long term goal if someone where to spend time on this.. I guess
 I'd prefer a more incremental approach of converting parts one by one
 if I were doing it myself.  It's kind of a moot point either way until
 someone has time/motivation to spend on it.

 But I've no real objection to dropping ilo until then if others feel
 strongly.. it's still there in git history so it can be resurrected if
 someone wants to convert to reuse other i965 bits incrementally rather
 than starting from scratch.
>>>
>>> As mentioned on IRC, I think the real use-case that ilo could cover
>>> that i965/anv can't (easily) handle is acting as a gallium-nine
>>> backend. (I know someone's working on DX9 over vulkan, but that's
>>> hardly ready, and will never be available on gen6.)
>>>
>>> However at this time, it's not sufficiently functional to handle
>>> gallium-nine, so I don't see any serious downside to dropping it.
>>>
>>>   -ilia
>>>
>>
>>
>>
>> ___
>> 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] radv/ac: no need to pass nir to the post outputs handling

2016-12-07 Thread Dave Airlie
From: Dave Airlie 

We don't use the nir shader in here at all.

Signed-off-by: Dave Airlie 
---
 src/amd/common/ac_nir_to_llvm.c | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index bb52e8f..f5f78a3 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -4369,8 +4369,7 @@ si_llvm_init_export_args(struct nir_to_llvm_context *ctx,
 }
 
 static void
-handle_vs_outputs_post(struct nir_to_llvm_context *ctx,
- struct nir_shader *nir)
+handle_vs_outputs_post(struct nir_to_llvm_context *ctx)
 {
uint32_t param_count = 0;
unsigned target;
@@ -4572,8 +4571,7 @@ si_export_mrt_z(struct nir_to_llvm_context *ctx,
 }
 
 static void
-handle_fs_outputs_post(struct nir_to_llvm_context *ctx,
-  struct nir_shader *nir)
+handle_fs_outputs_post(struct nir_to_llvm_context *ctx)
 {
unsigned index = 0;
LLVMValueRef depth = NULL, stencil = NULL, samplemask = NULL;
@@ -4615,15 +4613,14 @@ handle_fs_outputs_post(struct nir_to_llvm_context *ctx,
 }
 
 static void
-handle_shader_outputs_post(struct nir_to_llvm_context *ctx,
-  struct nir_shader *nir)
+handle_shader_outputs_post(struct nir_to_llvm_context *ctx)
 {
switch (ctx->stage) {
case MESA_SHADER_VERTEX:
-   handle_vs_outputs_post(ctx, nir);
+   handle_vs_outputs_post(ctx);
break;
case MESA_SHADER_FRAGMENT:
-   handle_fs_outputs_post(ctx, nir);
+   handle_fs_outputs_post(ctx);
break;
default:
break;
@@ -4741,7 +4738,7 @@ LLVMModuleRef 
ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
visit_cf_list(, >impl->body);
phi_post_pass();
 
-   handle_shader_outputs_post(, nir);
+   handle_shader_outputs_post();
LLVMBuildRetVoid(ctx.builder);
 
ac_llvm_finalize_module();
-- 
2.7.4

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


[Mesa-dev] [PATCH mesa 1/2] egl: rename static functions to match convention

2016-12-07 Thread Eric Engestrom
Signed-off-by: Eric Engestrom 
---
 src/egl/main/eglapi.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 9950a72..925e881 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -890,7 +890,7 @@ eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
 }
 
 static void *
-fixupNativeWindow(_EGLDisplay *disp, void *native_window)
+_fixupNativeWindow(_EGLDisplay *disp, void *native_window)
 {
 #ifdef HAVE_X11_PLATFORM
if (disp->Platform == _EGL_PLATFORM_X11 && native_window != NULL) {
@@ -914,7 +914,7 @@ eglCreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig 
config,
 {
_EGLDisplay *disp = _eglLockDisplay(dpy);
 
-   native_window = fixupNativeWindow(disp, native_window);
+   native_window = _fixupNativeWindow(disp, native_window);
 
_EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_SURFACE);
return _eglCreateWindowSurfaceCommon(disp, config, native_window,
@@ -937,7 +937,7 @@ eglCreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig 
config,
if (attrib_list && !int_attribs)
   RETURN_EGL_ERROR(disp, EGL_BAD_ALLOC, EGL_NO_SURFACE);
 
-   native_window = fixupNativeWindow(disp, native_window);
+   native_window = _fixupNativeWindow(disp, native_window);
surface = _eglCreateWindowSurfaceCommon(disp, config, native_window,
int_attribs);
free(int_attribs);
@@ -945,7 +945,7 @@ eglCreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig 
config,
 }
 
 static void *
-fixupNativePixmap(_EGLDisplay *disp, void *native_pixmap)
+_fixupNativePixmap(_EGLDisplay *disp, void *native_pixmap)
 {
 #ifdef HAVE_X11_PLATFORM
   /* The `native_pixmap` parameter for the X11 platform differs between
@@ -1015,7 +1015,7 @@ eglCreatePlatformPixmapSurfaceEXT(EGLDisplay dpy, 
EGLConfig config,
_EGLDisplay *disp = _eglLockDisplay(dpy);
 
_EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_SURFACE);
-   native_pixmap = fixupNativePixmap(disp, native_pixmap);
+   native_pixmap = _fixupNativePixmap(disp, native_pixmap);
return _eglCreatePixmapSurfaceCommon(disp, config, native_pixmap,
 attrib_list);
 }
@@ -1036,7 +1036,7 @@ eglCreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig 
config,
if (attrib_list && !int_attribs)
   RETURN_EGL_ERROR(disp, EGL_BAD_ALLOC, EGL_NO_SURFACE);
 
-   native_pixmap = fixupNativePixmap(disp, native_pixmap);
+   native_pixmap = _fixupNativePixmap(disp, native_pixmap);
surface = _eglCreatePixmapSurfaceCommon(disp, config, native_pixmap,
int_attribs);
free(int_attribs);
@@ -2208,7 +2208,7 @@ eglLabelObjectKHR(EGLDisplay dpy, EGLenum objectType, 
EGLObjectKHR object,
 }
 
 static EGLBoolean
-validDebugMessageLevel(EGLAttrib level)
+_validDebugMessageLevel(EGLAttrib level)
 {
return (level >= EGL_DEBUG_MSG_CRITICAL_KHR &&
level <= EGL_DEBUG_MSG_INFO_KHR);
@@ -2229,7 +2229,7 @@ eglDebugMessageControlKHR(EGLDEBUGPROCKHR callback,
   int i;
 
   for (i = 0; attrib_list[i] != EGL_NONE; i += 2) {
- if (validDebugMessageLevel(attrib_list[i])) {
+ if (_validDebugMessageLevel(attrib_list[i])) {
 if (attrib_list[i + 1])
newEnabled |= DebugBitFromType(attrib_list[i]);
 else
@@ -2266,7 +2266,7 @@ eglQueryDebugKHR(EGLint attribute, EGLAttrib *value)
mtx_lock(_eglGlobal.Mutex);
 
do {
-  if (validDebugMessageLevel(attribute)) {
+  if (_validDebugMessageLevel(attribute)) {
  if (_eglGlobal.debugTypesEnabled & DebugBitFromType(attribute))
 *value = EGL_TRUE;
  else
-- 
Cheers,
  Eric

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


[Mesa-dev] [PATCH mesa 2/2] egl: unexport _eglConvertIntsToAttribs

2016-12-07 Thread Eric Engestrom
Nobody else makes use of this function.
We can always re-export it if someone ever needs it.

Signed-off-by: Eric Engestrom 
---
 src/egl/main/eglapi.c | 2 +-
 src/egl/main/eglapi.h | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 925e881..1716ffa 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -288,7 +288,7 @@ _eglSetFuncName(const char *funcName, _EGLDisplay *disp, 
EGLenum objectType, _EG
  * Return an EGL error code. The output parameter out_attrib_list is modified
  * only on success.
  */
-EGLint
+static EGLint
 _eglConvertIntsToAttribs(const EGLint *int_list, EGLAttrib **out_attrib_list)
 {
size_t len = 0;
diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
index 2dc89fc..710c5d8 100644
--- a/src/egl/main/eglapi.h
+++ b/src/egl/main/eglapi.h
@@ -200,9 +200,6 @@ struct _egl_api
 struct mesa_glinterop_export_out *out);
 };
 
-EGLint _eglConvertIntsToAttribs(const EGLint *int_list,
-EGLAttrib **out_attrib_list);
-
 #ifdef __cplusplus
 }
 #endif
-- 
Cheers,
  Eric

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


Re: [Mesa-dev] Potentially EOL ilo gallium driver

2016-12-07 Thread Edward O'Callaghan


On 12/08/2016 11:28 AM, Roland Scheidegger wrote:
> I haven't seen the driver author's opinion on this yet, so it's probably
> fair to give him some more time to answer. It's not like this is really
> urgent...

Absolutely!

> 
> Roland
> 
> Am 08.12.2016 um 01:11 schrieb Edward O'Callaghan:
>> Hi all,
>>
>> So I'll get right to the crux of this; In summary the consensus would
>> then be to drop ilo?
>>
>> If so, I am not sure of this communities procedure? However, if it helps
>> the patch is here:
>> https://cgit.freedesktop.org/~funfunctor/mesa/log/?h=eol-ilo
>>
>> Kind Regards,
>> Edward.
>>
>> On 12/07/2016 07:08 AM, Ilia Mirkin wrote:
>>> On Tue, Dec 6, 2016 at 3:00 PM, Rob Clark  wrote:
 On Tue, Dec 6, 2016 at 2:11 PM, Jason Ekstrand  
 wrote:
> On Tue, Dec 6, 2016 at 8:39 AM, Rob Clark  wrote:
>>
>> On Tue, Dec 6, 2016 at 8:42 AM, Emil Velikov 
>> wrote:
>>> On 6 December 2016 at 03:16, Edward O'Callaghan
>>>  wrote:
 This patch is to potentially remove ourself from the maintaince
 burden of the ilo driver that appears to now be essentially
 unmaintained?

 I am not sure of our policy here or if there are too many
 users so this patch is really only to gauge a response of
 how folks feel?

>>> Surely you want to CC the core/sole developer of the driver when
>>> considering its removal.
>>> Maybe mailman was "nice" and hid his email in the header ;-)
>>>
>>> Either way adding Chia-I Wu to the list.
>>>
>>> -Emil
>>> P.S. Not sure/sold how much of an actual burden the driver is, yet I
>>> don't make serious gallium infra changes.
>>
>> really hasn't been a problem for me..
>>
>> That said, it would be nice if someday someone wired this up to use
>> glsl_to_nir path in gallium and re-used i965's nir backend.  I think
>> that would make ilo somewhat more interesting..
>
>
> We had a bit of a chat about this on IRC and what I told Ilia there was 
> that
> the more interesting thing to do, if someone really wanted to do Intel on
> gallium, would probably be to build a new driver based on ISL, blorp, the
> i965 compiler, NIR, and genxml.  We've made a pretty good driver-building
> toolbox.  Having an almost unmaintained driver that has it's own 
> hand-rolled
> and inferrior compiler, surface layout, etc. isn't doing much good.
>

 yeah, reusing the other bits would be nice too, and hopefully would be
 the long term goal if someone where to spend time on this.. I guess
 I'd prefer a more incremental approach of converting parts one by one
 if I were doing it myself.  It's kind of a moot point either way until
 someone has time/motivation to spend on it.

 But I've no real objection to dropping ilo until then if others feel
 strongly.. it's still there in git history so it can be resurrected if
 someone wants to convert to reuse other i965 bits incrementally rather
 than starting from scratch.
>>>
>>> As mentioned on IRC, I think the real use-case that ilo could cover
>>> that i965/anv can't (easily) handle is acting as a gallium-nine
>>> backend. (I know someone's working on DX9 over vulkan, but that's
>>> hardly ready, and will never be available on gen6.)
>>>
>>> However at this time, it's not sufficiently functional to handle
>>> gallium-nine, so I don't see any serious downside to dropping it.
>>>
>>>   -ilia
>>>
>>
>>
>>
>> ___
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>
> 



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


[Mesa-dev] [PATCH mesa] egl/x11: cleanup init code

2016-12-07 Thread Eric Engestrom
No functional change, just rewriting it in an easier-to-understand way.

Signed-off-by: Eric Engestrom 
---
 src/egl/drivers/dri2/platform_x11.c | 24 ++--
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_x11.c 
b/src/egl/drivers/dri2/platform_x11.c
index df39ca8..db7d3b9 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -1467,24 +1467,20 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay 
*disp)
 EGLBoolean
 dri2_initialize_x11(_EGLDriver *drv, _EGLDisplay *disp)
 {
-   EGLBoolean initialized = EGL_TRUE;
+   EGLBoolean initialized = EGL_FALSE;
 
-   int x11_dri2_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);
-
-   if (x11_dri2_accel) {
+   if (!getenv("LIBGL_ALWAYS_SOFTWARE")) {
 #ifdef HAVE_DRI3
-  if (getenv("LIBGL_DRI3_DISABLE") != NULL ||
-  !dri2_initialize_x11_dri3(drv, disp)) {
+  if (!getenv("LIBGL_DRI3_DISABLE"))
+ initialized = dri2_initialize_x11_dri3(drv, disp);
 #endif
+
+  if (!initialized)
- if (!dri2_initialize_x11_dri2(drv, disp)) {
+ initialized = dri2_initialize_x11_dri2(drv, disp);
-initialized = dri2_initialize_x11_swrast(drv, disp);
- }
-#ifdef HAVE_DRI3
-  }
-#endif
-   } else {
+   }
+
+   if (!initialized)
   initialized = dri2_initialize_x11_swrast(drv, disp);
-   }
 
return initialized;
 }
-- 
Cheers,
  Eric

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


Re: [Mesa-dev] radv cleanup series

2016-12-07 Thread Edward O'Callaghan
This series is,
Reviewed-by: Edward O'Callaghan 

On 12/08/2016 11:18 AM, Dave Airlie wrote:
> While working on spilling, geom shaders and compute queues, I've built
> up a bunch of cleanups, so best to dequeue them early.
> 
> Dave.
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 



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


Re: [Mesa-dev] Potentially EOL ilo gallium driver

2016-12-07 Thread Roland Scheidegger
I haven't seen the driver author's opinion on this yet, so it's probably
fair to give him some more time to answer. It's not like this is really
urgent...

Roland

Am 08.12.2016 um 01:11 schrieb Edward O'Callaghan:
> Hi all,
> 
> So I'll get right to the crux of this; In summary the consensus would
> then be to drop ilo?
> 
> If so, I am not sure of this communities procedure? However, if it helps
> the patch is here:
> https://cgit.freedesktop.org/~funfunctor/mesa/log/?h=eol-ilo
> 
> Kind Regards,
> Edward.
> 
> On 12/07/2016 07:08 AM, Ilia Mirkin wrote:
>> On Tue, Dec 6, 2016 at 3:00 PM, Rob Clark  wrote:
>>> On Tue, Dec 6, 2016 at 2:11 PM, Jason Ekstrand  wrote:
 On Tue, Dec 6, 2016 at 8:39 AM, Rob Clark  wrote:
>
> On Tue, Dec 6, 2016 at 8:42 AM, Emil Velikov 
> wrote:
>> On 6 December 2016 at 03:16, Edward O'Callaghan
>>  wrote:
>>> This patch is to potentially remove ourself from the maintaince
>>> burden of the ilo driver that appears to now be essentially
>>> unmaintained?
>>>
>>> I am not sure of our policy here or if there are too many
>>> users so this patch is really only to gauge a response of
>>> how folks feel?
>>>
>> Surely you want to CC the core/sole developer of the driver when
>> considering its removal.
>> Maybe mailman was "nice" and hid his email in the header ;-)
>>
>> Either way adding Chia-I Wu to the list.
>>
>> -Emil
>> P.S. Not sure/sold how much of an actual burden the driver is, yet I
>> don't make serious gallium infra changes.
>
> really hasn't been a problem for me..
>
> That said, it would be nice if someday someone wired this up to use
> glsl_to_nir path in gallium and re-used i965's nir backend.  I think
> that would make ilo somewhat more interesting..


 We had a bit of a chat about this on IRC and what I told Ilia there was 
 that
 the more interesting thing to do, if someone really wanted to do Intel on
 gallium, would probably be to build a new driver based on ISL, blorp, the
 i965 compiler, NIR, and genxml.  We've made a pretty good driver-building
 toolbox.  Having an almost unmaintained driver that has it's own 
 hand-rolled
 and inferrior compiler, surface layout, etc. isn't doing much good.

>>>
>>> yeah, reusing the other bits would be nice too, and hopefully would be
>>> the long term goal if someone where to spend time on this.. I guess
>>> I'd prefer a more incremental approach of converting parts one by one
>>> if I were doing it myself.  It's kind of a moot point either way until
>>> someone has time/motivation to spend on it.
>>>
>>> But I've no real objection to dropping ilo until then if others feel
>>> strongly.. it's still there in git history so it can be resurrected if
>>> someone wants to convert to reuse other i965 bits incrementally rather
>>> than starting from scratch.
>>
>> As mentioned on IRC, I think the real use-case that ilo could cover
>> that i965/anv can't (easily) handle is acting as a gallium-nine
>> backend. (I know someone's working on DX9 over vulkan, but that's
>> hardly ready, and will never be available on gen6.)
>>
>> However at this time, it's not sufficiently functional to handle
>> gallium-nine, so I don't see any serious downside to dropping it.
>>
>>   -ilia
>>
> 
> 
> 
> ___
> 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 1/2] radv: name memory heaps

2016-12-07 Thread Eric Engestrom
Give explicit names to the various memory heaps, reducing the risk of
bugs when adding or modifying them.

While at it, use a static_assert to make sure we don't have too many
memory heaps.

Signed-off-by: Eric Engestrom 
---

I'm sure there are better names than these, but this patch is here to
suggest using names. Feel free to use better names :)

---
 src/amd/vulkan/radv_device.c | 23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 0defc0f..ed71bb6 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -575,40 +575,49 @@ void radv_GetPhysicalDeviceMemoryProperties(
 {
RADV_FROM_HANDLE(radv_physical_device, physical_device, physicalDevice);
 
+   enum memoryHeaps {
+   heapVramNonVisible,
+   heapVramVisible,
+   heapGart,
+   _heapCount,
+   };
+
+   STATIC_ASSERT(_heapCount <= VK_MAX_MEMORY_HEAPS);
+
pMemoryProperties->memoryTypeCount = 4;
pMemoryProperties->memoryTypes[0] = (VkMemoryType) {
.propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
-   .heapIndex = 0,
+   .heapIndex = heapVramNonVisible,
};
pMemoryProperties->memoryTypes[1] = (VkMemoryType) {
.propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-   .heapIndex = 2,
+   .heapIndex = heapGart,
};
pMemoryProperties->memoryTypes[2] = (VkMemoryType) {
.propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-   .heapIndex = 1,
+   .heapIndex = heapVramVisible,
};
pMemoryProperties->memoryTypes[3] = (VkMemoryType) {
.propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
-   .heapIndex = 2,
+   .heapIndex = heapGart,
};
 
-   pMemoryProperties->memoryHeapCount = 3;
+   pMemoryProperties->memoryHeapCount = _heapCount;
-   pMemoryProperties->memoryHeaps[0] = (VkMemoryHeap) {
+   pMemoryProperties->memoryHeaps[heapVramNonVisible] = (VkMemoryHeap) {
.size = physical_device->rad_info.vram_size -
physical_device->rad_info.visible_vram_size,
.flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
};
-   pMemoryProperties->memoryHeaps[1] = (VkMemoryHeap) {
+   pMemoryProperties->memoryHeaps[heapVramVisible] = (VkMemoryHeap) {
.size = physical_device->rad_info.visible_vram_size,
.flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
};
-   pMemoryProperties->memoryHeaps[2] = (VkMemoryHeap) {
+   pMemoryProperties->memoryHeaps[heapGart] = (VkMemoryHeap) {
.size = physical_device->rad_info.gart_size,
.flags = 0,
};
-- 
Cheers,
  Eric

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


[Mesa-dev] [PATCH mesa 2/2] radv: name memory types

2016-12-07 Thread Eric Engestrom
Following the previous patch, give explicit names to the various memory types,
reducing the risk of bugs when adding or modifying them.

While at it, use a static_assert to make sure we don't have too many
memory types.

Signed-off-by: Eric Engestrom 
---

This one isn't really useful yet, but I thought I'd suggest it anyway :)

---
 src/amd/vulkan/radv_device.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index ed71bb6..0c8b39f 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -575,6 +575,16 @@ void radv_GetPhysicalDeviceMemoryProperties(
 {
RADV_FROM_HANDLE(radv_physical_device, physical_device, physicalDevice);
 
+   enum memoryTypes {
+   typeDeviceLocal,
+   typeHostVisibleCoherent,
+   typeDeviceLocalHostVisibleCoherent,
+   typeHostVisibleCoherentCached,
+   _typeCount,
+   };
+
+   STATIC_ASSERT(_typeCount <= VK_MAX_MEMORY_TYPES);
+
enum memoryHeaps {
heapVramNonVisible,
heapVramVisible,
@@ -582,22 +593,22 @@ void radv_GetPhysicalDeviceMemoryProperties(
STATIC_ASSERT(_heapCount <= VK_MAX_MEMORY_HEAPS);
 
-   pMemoryProperties->memoryTypeCount = 4;
+   pMemoryProperties->memoryTypeCount = _typeCount;
-   pMemoryProperties->memoryTypes[0] = (VkMemoryType) {
+   pMemoryProperties->memoryTypes[typeDeviceLocal] = (VkMemoryType) {
.propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
.heapIndex = heapVramNonVisible,
};
-   pMemoryProperties->memoryTypes[1] = (VkMemoryType) {
+   pMemoryProperties->memoryTypes[typeHostVisibleCoherent] = 
(VkMemoryType) {
.propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
.heapIndex = heapGart,
};
-   pMemoryProperties->memoryTypes[2] = (VkMemoryType) {
+   pMemoryProperties->memoryTypes[typeDeviceLocalHostVisibleCoherent] = 
(VkMemoryType) {
.propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
.heapIndex = heapVramVisible,
};
-   pMemoryProperties->memoryTypes[3] = (VkMemoryType) {
+   pMemoryProperties->memoryTypes[typeHostVisibleCoherentCached] = 
(VkMemoryType) {
.propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
-- 
Cheers,
  Eric

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


[Mesa-dev] [PATCH 06/10] radv/meta: cleanup image info setup.

2016-12-07 Thread Dave Airlie
From: Dave Airlie 

This just passes the subresource info in and uses it.

Signed-off-by: Dave Airlie 
---
 src/amd/vulkan/radv_meta_copy.c | 32 +---
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_copy.c b/src/amd/vulkan/radv_meta_copy.c
index 6333e5c..d81fc48 100644
--- a/src/amd/vulkan/radv_meta_copy.c
+++ b/src/amd/vulkan/radv_meta_copy.c
@@ -78,13 +78,13 @@ vk_format_for_size(int bs)
 }
 
 static struct radv_meta_blit2d_surf
-blit_surf_for_image_level_layer(struct radv_image* image, VkImageAspectFlags 
aspectMask,
-   int level, int layer)
+blit_surf_for_image_level_layer(struct radv_image *image,
+   const VkImageSubresourceLayers *subres)
 {
VkFormat format = image->vk_format;
-   if (aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT)
+   if (subres->aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT)
format = vk_format_depth_only(format);
-   else if (aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT)
+   else if (subres->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT)
format = vk_format_stencil_only(format);
 
if (!image->surface.dcc_size)
@@ -93,10 +93,10 @@ blit_surf_for_image_level_layer(struct radv_image* image, 
VkImageAspectFlags asp
return (struct radv_meta_blit2d_surf) {
.format = format,
.bs = vk_format_get_blocksize(format),
-   .level = level,
-   .layer = layer,
+   .level = subres->mipLevel,
+   .layer = subres->baseArrayLayer,
.image = image,
-   .aspect_mask = aspectMask,
+   .aspect_mask = subres->aspectMask,
};
 }
 
@@ -150,9 +150,7 @@ meta_copy_buffer_to_image(struct radv_cmd_buffer 
*cmd_buffer,
/* Create blit surfaces */
struct radv_meta_blit2d_surf img_bsurf =
blit_surf_for_image_level_layer(image,
-   
pRegions[r].imageSubresource.aspectMask,
-   
pRegions[r].imageSubresource.mipLevel,
-   
pRegions[r].imageSubresource.baseArrayLayer);
+   
[r].imageSubresource);
 
struct radv_meta_blit2d_buffer buf_bsurf = {
.bs = img_bsurf.bs,
@@ -253,9 +251,8 @@ meta_copy_image_to_buffer(struct radv_cmd_buffer 
*cmd_buffer,
/* Create blit surfaces */
struct radv_meta_blit2d_surf img_info =
blit_surf_for_image_level_layer(image,
-   
pRegions[r].imageSubresource.aspectMask,
-   
pRegions[r].imageSubresource.mipLevel,
-   
pRegions[r].imageSubresource.baseArrayLayer);
+   
[r].imageSubresource);
+
struct radv_meta_blit2d_buffer buf_info = {
.bs = img_info.bs,
.format = img_info.format,
@@ -331,14 +328,11 @@ meta_copy_image(struct radv_cmd_buffer *cmd_buffer,
/* Create blit surfaces */
struct radv_meta_blit2d_surf b_src =
blit_surf_for_image_level_layer(src_image,
-   
pRegions[r].srcSubresource.aspectMask,
-   
pRegions[r].srcSubresource.mipLevel,
-   
pRegions[r].srcSubresource.baseArrayLayer);
+   
[r].srcSubresource);
+
struct radv_meta_blit2d_surf b_dst =
blit_surf_for_image_level_layer(dest_image,
-   
pRegions[r].dstSubresource.aspectMask,
-   
pRegions[r].dstSubresource.mipLevel,
-   
pRegions[r].dstSubresource.baseArrayLayer);
+   
[r].dstSubresource);
 
/* for DCC */
b_src.format = b_dst.format;
-- 
2.7.4

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


[Mesa-dev] [PATCH 07/10] radv/meta: don't pass rect into blit2d src function.

2016-12-07 Thread Dave Airlie
From: Dave Airlie 

Signed-off-by: Dave Airlie 
---
 src/amd/vulkan/radv_meta_blit2d.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_blit2d.c 
b/src/amd/vulkan/radv_meta_blit2d.c
index 6e92f80..5a42fd8 100644
--- a/src/amd/vulkan/radv_meta_blit2d.c
+++ b/src/amd/vulkan/radv_meta_blit2d.c
@@ -112,7 +112,6 @@ static void
 blit2d_bind_src(struct radv_cmd_buffer *cmd_buffer,
 struct radv_meta_blit2d_surf *src_img,
 struct radv_meta_blit2d_buffer *src_buf,
-struct radv_meta_blit2d_rect *rect,
 struct blit2d_src_temps *tmp,
 enum blit2d_src_type src_type, VkFormat depth_format)
 {
@@ -287,7 +286,7 @@ radv_meta_blit2d_normal_dst(struct radv_cmd_buffer 
*cmd_buffer,
if (dst->aspect_mask != VK_IMAGE_ASPECT_COLOR_BIT)
depth_format = dst->image->vk_format;
struct blit2d_src_temps src_temps;
-   blit2d_bind_src(cmd_buffer, src_img, src_buf, [r], 
_temps, src_type, depth_format);
+   blit2d_bind_src(cmd_buffer, src_img, src_buf, _temps, 
src_type, depth_format);
 
uint32_t offset = 0;
struct blit2d_dst_temps dst_temps;
-- 
2.7.4

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


[Mesa-dev] [PATCH 09/10] radv/ac: pass a mask of array params not a number.

2016-12-07 Thread Dave Airlie
From: Dave Airlie 

This makes it easier to add new params before the array ones.

Signed-off-by: Dave Airlie 
---
 src/amd/common/ac_nir_to_llvm.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 84a1e24..5820e62 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -275,7 +275,7 @@ static LLVMValueRef
 create_llvm_function(LLVMContextRef ctx, LLVMModuleRef module,
  LLVMBuilderRef builder, LLVMTypeRef *return_types,
  unsigned num_return_elems, LLVMTypeRef *param_types,
- unsigned param_count, unsigned array_params,
+ unsigned param_count, unsigned array_params_mask,
  unsigned sgpr_params, bool unsafe_math)
 {
LLVMTypeRef main_function_type, ret_type;
@@ -298,7 +298,7 @@ create_llvm_function(LLVMContextRef ctx, LLVMModuleRef 
module,
 
LLVMSetFunctionCallConv(main_function, RADEON_LLVM_AMDGPU_CS);
for (unsigned i = 0; i < sgpr_params; ++i) {
-   if (i < array_params) {
+   if (array_params_mask & (1 << i)) {
LLVMValueRef P = LLVMGetParam(main_function, i);
ac_add_function_attr(main_function, i + 1, 
AC_FUNC_ATTR_BYVAL);
ac_add_attr_dereferenceable(P, UINT64_MAX);
@@ -455,7 +455,7 @@ static void create_function(struct nir_to_llvm_context *ctx)
 {
LLVMTypeRef arg_types[23];
unsigned arg_idx = 0;
-   unsigned array_count = 0;
+   unsigned array_params_mask = 0;
unsigned sgpr_count = 0, user_sgpr_count;
unsigned i;
unsigned num_sets = ctx->options->layout ? 
ctx->options->layout->num_sets : 0;
@@ -472,16 +472,17 @@ static void create_function(struct nir_to_llvm_context 
*ctx)
/* 1 for each descriptor set */
for (unsigned i = 0; i < num_sets; ++i) {
if (ctx->options->layout->set[i].layout->shader_stages & (1 << 
ctx->stage)) {
+   array_params_mask |= (1 << arg_idx);
arg_types[arg_idx++] = const_array(ctx->i8, 1024 * 
1024);
}
}
 
if (need_push_constants) {
/* 1 for push constants and dynamic descriptors */
+   array_params_mask |= (1 << arg_idx);
arg_types[arg_idx++] = const_array(ctx->i8, 1024 * 1024);
}
 
-   array_count = arg_idx;
switch (ctx->stage) {
case MESA_SHADER_COMPUTE:
arg_types[arg_idx++] = LLVMVectorType(ctx->i32, 3); /* grid 
size */
@@ -530,7 +531,7 @@ static void create_function(struct nir_to_llvm_context *ctx)
 
ctx->main_function = create_llvm_function(
ctx->context, ctx->module, ctx->builder, NULL, 0, arg_types,
-   arg_idx, array_count, sgpr_count, ctx->options->unsafe_math);
+   arg_idx, array_params_mask, sgpr_count, ctx->options->unsafe_math);
set_llvm_calling_convention(ctx->main_function, ctx->stage);
 
 
-- 
2.7.4

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


[Mesa-dev] [PATCH 03/10] radv/ac: don't pass nir to create_function

2016-12-07 Thread Dave Airlie
From: Dave Airlie 

This isn't needed for later things like geom shader copy shaders,
we won't have NIR.

Signed-off-by: Dave Airlie 
---
 src/amd/common/ac_nir_to_llvm.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 0ad9a7a..84a1e24 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -451,8 +451,7 @@ static void set_userdata_location_indirect(struct 
ac_userdata_info *ud_info, uin
 }
 #endif
 
-static void create_function(struct nir_to_llvm_context *ctx,
-struct nir_shader *nir)
+static void create_function(struct nir_to_llvm_context *ctx)
 {
LLVMTypeRef arg_types[23];
unsigned arg_idx = 0;
@@ -483,7 +482,7 @@ static void create_function(struct nir_to_llvm_context *ctx,
}
 
array_count = arg_idx;
-   switch (nir->stage) {
+   switch (ctx->stage) {
case MESA_SHADER_COMPUTE:
arg_types[arg_idx++] = LLVMVectorType(ctx->i32, 3); /* grid 
size */
user_sgpr_count = arg_idx;
@@ -532,7 +531,7 @@ static void create_function(struct nir_to_llvm_context *ctx,
ctx->main_function = create_llvm_function(
ctx->context, ctx->module, ctx->builder, NULL, 0, arg_types,
arg_idx, array_count, sgpr_count, ctx->options->unsafe_math);
-   set_llvm_calling_convention(ctx->main_function, nir->stage);
+   set_llvm_calling_convention(ctx->main_function, ctx->stage);
 
 
ctx->shader_info->num_input_sgprs = 0;
@@ -545,7 +544,7 @@ static void create_function(struct nir_to_llvm_context *ctx,
for (; i < sgpr_count; i++)
ctx->shader_info->num_input_sgprs += 
llvm_get_type_size(arg_types[i]) / 4;
 
-   if (nir->stage != MESA_SHADER_FRAGMENT)
+   if (ctx->stage != MESA_SHADER_FRAGMENT)
for (; i < arg_idx; ++i)
ctx->shader_info->num_input_vgprs += 
llvm_get_type_size(arg_types[i]) / 4;
 
@@ -567,7 +566,7 @@ static void create_function(struct nir_to_llvm_context *ctx,
user_sgpr_idx += 2;
}
 
-   switch (nir->stage) {
+   switch (ctx->stage) {
case MESA_SHADER_COMPUTE:
set_userdata_location_shader(ctx, AC_UD_CS_GRID_SIZE, 
user_sgpr_idx, 3);
user_sgpr_idx += 3;
@@ -4680,7 +4679,7 @@ LLVMModuleRef 
ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
for (i = 0; i < AC_UD_MAX_UD; i++)
shader_info->user_sgprs_locs.shader_data[i].sgpr_idx = -1;
 
-   create_function(, nir);
+   create_function();
 
if (nir->stage == MESA_SHADER_COMPUTE) {
int num_shared = 0;
-- 
2.7.4

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


[Mesa-dev] [PATCH 02/10] radv: add missing license file to radv_meta_bufimage.

2016-12-07 Thread Dave Airlie
From: Dave Airlie 

Just noticed this file was missing license and any
explaination of what is in it.

Signed-off-by: Dave Airlie 
---
 src/amd/vulkan/radv_meta_bufimage.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/src/amd/vulkan/radv_meta_bufimage.c 
b/src/amd/vulkan/radv_meta_bufimage.c
index c9dd072..a2c5fb4 100644
--- a/src/amd/vulkan/radv_meta_bufimage.c
+++ b/src/amd/vulkan/radv_meta_bufimage.c
@@ -1,6 +1,33 @@
+/*
+ * Copyright © 2016 Red Hat.
+ * Copyright © 2016 Bas Nieuwenhuizen
+ *
+ * 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.
+ */
 #include "radv_meta.h"
 #include "nir/nir_builder.h"
 
+/*
+ * Compute shader implementation of image->buffer copy.
+ */
+
 static nir_shader *
 build_nir_itob_compute_shader(struct radv_device *dev)
 {
-- 
2.7.4

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


[Mesa-dev] [PATCH 08/10] radv: split out a chunk of variant filling code.

2016-12-07 Thread Dave Airlie
From: Dave Airlie 

This code will have use for copy shaders etc.

Signed-off-by: Dave Airlie 
---
 src/amd/vulkan/radv_pipeline.c | 76 --
 1 file changed, 43 insertions(+), 33 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 23ed2d2..f7e60c9 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -342,43 +342,19 @@ void radv_shader_variant_destroy(struct radv_device 
*device,
free(variant);
 }
 
-static
-struct radv_shader_variant *radv_shader_variant_create(struct radv_device 
*device,
-   struct nir_shader 
*shader,
-   struct 
radv_pipeline_layout *layout,
-   const union 
ac_shader_variant_key *key,
-  void** code_out,
-  unsigned *code_size_out,
-  bool dump)
+static void radv_fill_shader_variant(struct radv_device *device,
+struct radv_shader_variant *variant,
+struct ac_shader_binary *binary,
+gl_shader_stage stage)
 {
-   struct radv_shader_variant *variant = calloc(1, sizeof(struct 
radv_shader_variant));
-   enum radeon_family chip_family = 
device->instance->physicalDevice.rad_info.family;
-   LLVMTargetMachineRef tm;
-   if (!variant)
-   return NULL;
-
-   struct ac_nir_compiler_options options = {0};
-   options.layout = layout;
-   if (key)
-   options.key = *key;
-
-   struct ac_shader_binary binary;
-
-   options.unsafe_math = env_var_as_boolean("RADV_UNSAFE_MATH", false);
-   options.family = chip_family;
-   options.chip_class = 
device->instance->physicalDevice.rad_info.chip_class;
-   tm = ac_create_target_machine(chip_family);
-   ac_compile_nir_shader(tm, , >config,
- >info, shader, , dump);
-   LLVMDisposeTargetMachine(tm);
-
-   variant->code_size = binary.code_size;
+   variant->code_size = binary->code_size;
bool scratch_enabled = variant->config.scratch_bytes_per_wave > 0;
unsigned vgpr_comp_cnt = 0;
 
if (scratch_enabled)
radv_finishme("shader scratch space");
-   switch (shader->stage) {
+
+   switch (stage) {
case MESA_SHADER_VERTEX:
variant->rsrc2 = 
S_00B12C_USER_SGPR(variant->info.num_user_sgprs) |
S_00B12C_SCRATCH_EN(scratch_enabled);
@@ -407,13 +383,47 @@ struct radv_shader_variant 
*radv_shader_variant_create(struct radv_device *devic
S_00B848_DX10_CLAMP(1) |
S_00B848_FLOAT_MODE(variant->config.float_mode);
 
-   variant->bo = device->ws->buffer_create(device->ws, binary.code_size, 
256,
+   variant->bo = device->ws->buffer_create(device->ws, binary->code_size, 
256,
RADEON_DOMAIN_GTT, 
RADEON_FLAG_CPU_ACCESS);
 
void *ptr = device->ws->buffer_map(variant->bo);
-   memcpy(ptr, binary.code, binary.code_size);
+   memcpy(ptr, binary->code, binary->code_size);
device->ws->buffer_unmap(variant->bo);
 
+
+}
+
+static struct radv_shader_variant *radv_shader_variant_create(struct 
radv_device *device,
+ struct nir_shader 
*shader,
+ struct 
radv_pipeline_layout *layout,
+ const union 
ac_shader_variant_key *key,
+ void** code_out,
+ unsigned 
*code_size_out,
+ bool dump)
+{
+   struct radv_shader_variant *variant = calloc(1, sizeof(struct 
radv_shader_variant));
+   enum radeon_family chip_family = 
device->instance->physicalDevice.rad_info.family;
+   LLVMTargetMachineRef tm;
+   if (!variant)
+   return NULL;
+
+   struct ac_nir_compiler_options options = {0};
+   options.layout = layout;
+   if (key)
+   options.key = *key;
+
+   struct ac_shader_binary binary;
+
+   options.unsafe_math = env_var_as_boolean("RADV_UNSAFE_MATH", false);
+   options.family = chip_family;
+   options.chip_class = 
device->instance->physicalDevice.rad_info.chip_class;
+   tm = ac_create_target_machine(chip_family);
+   ac_compile_nir_shader(tm, , >config,
+ >info, shader, , dump);
+   LLVMDisposeTargetMachine(tm);
+
+   

[Mesa-dev] [PATCH 10/10] radv: fix warnings in ubo load code.

2016-12-07 Thread Dave Airlie
From: Dave Airlie 

Signed-off-by: Dave Airlie 
---
 src/amd/common/ac_nir_to_llvm.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 5820e62..c2a74d4 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -2095,9 +2095,6 @@ static LLVMValueRef visit_load_buffer(struct 
nir_to_llvm_context *ctx,
 static LLVMValueRef visit_load_ubo_buffer(struct nir_to_llvm_context *ctx,
   nir_intrinsic_instr *instr)
 {
-   const nir_intrinsic_info *info = _intrinsic_infos[instr->intrinsic];
-   const char *load_name;
-   LLVMTypeRef data_type = ctx->f32;
LLVMValueRef results[4], ret;
LLVMValueRef rsrc = get_src(ctx, instr->src[0]);
LLVMValueRef offset = get_src(ctx, instr->src[1]);
-- 
2.7.4

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


[Mesa-dev] [PATCH 04/10] radv/meta: clean up buffer->image code.

2016-12-07 Thread Dave Airlie
From: Dave Airlie 

Removes some unnecessary functions and pull
some stuff out of the loop.

Signed-off-by: Dave Airlie 
---
 src/amd/vulkan/radv_meta_bufimage.c | 42 +++--
 1 file changed, 7 insertions(+), 35 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_bufimage.c 
b/src/amd/vulkan/radv_meta_bufimage.c
index a2c5fb4..01e48e4 100644
--- a/src/amd/vulkan/radv_meta_bufimage.c
+++ b/src/amd/vulkan/radv_meta_bufimage.c
@@ -300,30 +300,11 @@ create_bview(struct radv_cmd_buffer *cmd_buffer,
 
 struct itob_temps {
struct radv_image_view src_iview;
-
struct radv_buffer_view dst_bview;
VkDescriptorSet set;
 };
 
 static void
-itob_bind_src_image(struct radv_cmd_buffer *cmd_buffer,
-  struct radv_meta_blit2d_surf *src,
-  struct radv_meta_blit2d_rect *rect,
-  struct itob_temps *tmp)
-{
-   create_iview(cmd_buffer, src, VK_IMAGE_USAGE_SAMPLED_BIT, 
>src_iview);
-}
-
-static void
-itob_bind_dst_buffer(struct radv_cmd_buffer *cmd_buffer,
-struct radv_meta_blit2d_buffer *dst,
-struct radv_meta_blit2d_rect *rect,
-struct itob_temps *tmp)
-{
-   create_bview(cmd_buffer, dst->buffer, dst->offset, dst->format, 
>dst_bview);
-}
-
-static void
 itob_bind_descriptors(struct radv_cmd_buffer *cmd_buffer,
  struct itob_temps *tmp)
 {
@@ -370,12 +351,6 @@ itob_bind_descriptors(struct radv_cmd_buffer *cmd_buffer,
 }
 
 static void
-itob_unbind_src_image(struct radv_cmd_buffer *cmd_buffer,
- struct itob_temps *temps)
-{
-}
-
-static void
 bind_pipeline(struct radv_cmd_buffer *cmd_buffer)
 {
VkPipeline pipeline =
@@ -395,16 +370,15 @@ radv_meta_image_to_buffer(struct radv_cmd_buffer 
*cmd_buffer,
  struct radv_meta_blit2d_rect *rects)
 {
struct radv_device *device = cmd_buffer->device;
+   struct itob_temps temps;
 
-   for (unsigned r = 0; r < num_rects; ++r) {
-   struct itob_temps temps;
-
-   itob_bind_src_image(cmd_buffer, src, [r], );
-   itob_bind_dst_buffer(cmd_buffer, dst, [r], );
-   itob_bind_descriptors(cmd_buffer, );
+   create_iview(cmd_buffer, src, VK_IMAGE_USAGE_SAMPLED_BIT, 
_iview);
+   create_bview(cmd_buffer, dst->buffer, dst->offset, dst->format, 
_bview);
+   itob_bind_descriptors(cmd_buffer, );
 
-   bind_pipeline(cmd_buffer);
+   bind_pipeline(cmd_buffer);
 
+   for (unsigned r = 0; r < num_rects; ++r) {
unsigned push_constants[3] = {
rects[r].src_x,
rects[r].src_y,
@@ -416,8 +390,6 @@ radv_meta_image_to_buffer(struct radv_cmd_buffer 
*cmd_buffer,
  push_constants);
 
radv_unaligned_dispatch(cmd_buffer, rects[r].width, 
rects[r].height, 1);
-   radv_temp_descriptor_set_destroy(cmd_buffer->device, temps.set);
-   itob_unbind_src_image(cmd_buffer, );
}
-
+   radv_temp_descriptor_set_destroy(cmd_buffer->device, temps.set);
 }
-- 
2.7.4

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


[Mesa-dev] [PATCH 05/10] radv/meta: split copyimage api into api and meta function

2016-12-07 Thread Dave Airlie
From: Dave Airlie 

This make it easier to add multiple queues later.

Signed-off-by: Dave Airlie 
---
 src/amd/vulkan/radv_meta_copy.c | 34 +++---
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_copy.c b/src/amd/vulkan/radv_meta_copy.c
index 4c01eb7..6333e5c 100644
--- a/src/amd/vulkan/radv_meta_copy.c
+++ b/src/amd/vulkan/radv_meta_copy.c
@@ -306,18 +306,13 @@ void radv_CmdCopyImageToBuffer(
  regionCount, pRegions);
 }
 
-void radv_CmdCopyImage(
-   VkCommandBuffer commandBuffer,
-   VkImage srcImage,
-   VkImageLayout   srcImageLayout,
-   VkImage destImage,
-   VkImageLayout   destImageLayout,
-   uint32_tregionCount,
-   const VkImageCopy*  pRegions)
+static void
+meta_copy_image(struct radv_cmd_buffer *cmd_buffer,
+   struct radv_image *src_image,
+   struct radv_image *dest_image,
+   uint32_t regionCount,
+   const VkImageCopy *pRegions)
 {
-   RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
-   RADV_FROM_HANDLE(radv_image, src_image, srcImage);
-   RADV_FROM_HANDLE(radv_image, dest_image, destImage);
struct radv_meta_saved_state saved_state;
 
/* From the Vulkan 1.0 spec:
@@ -397,3 +392,20 @@ void radv_CmdCopyImage(
 
radv_meta_restore(_state, cmd_buffer);
 }
+
+void radv_CmdCopyImage(
+   VkCommandBuffer commandBuffer,
+   VkImage srcImage,
+   VkImageLayout   srcImageLayout,
+   VkImage destImage,
+   VkImageLayout   destImageLayout,
+   uint32_tregionCount,
+   const VkImageCopy*  pRegions)
+{
+   RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
+   RADV_FROM_HANDLE(radv_image, src_image, srcImage);
+   RADV_FROM_HANDLE(radv_image, dest_image, destImage);
+
+   meta_copy_image(cmd_buffer, src_image, dest_image,
+   regionCount, pRegions);
+}
-- 
2.7.4

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


[Mesa-dev] [PATCH 01/10] radv/ac: use build_gep0 instead of opencoding it.

2016-12-07 Thread Dave Airlie
From: Dave Airlie 

Signed-off-by: Dave Airlie 
---
 src/amd/common/ac_nir_to_llvm.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index f644980..0ad9a7a 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -1898,9 +1898,8 @@ static LLVMValueRef visit_vulkan_resource_index(struct 
nir_to_llvm_context *ctx,
offset = LLVMConstInt(ctx->i32, base_offset, false);
index = LLVMBuildMul(ctx->builder, index, stride, "");
offset = LLVMBuildAdd(ctx->builder, offset, index, "");
-
-   LLVMValueRef indices[] = {ctx->i32zero, offset};
-   desc_ptr = LLVMBuildGEP(ctx->builder, desc_ptr, indices, 2, "");
+   
+   desc_ptr = build_gep0(ctx, desc_ptr, offset);
desc_ptr = cast_ptr(ctx, desc_ptr, ctx->v4i32);
LLVMSetMetadata(desc_ptr, ctx->uniform_md_kind, ctx->empty_md);
 
@@ -1912,8 +1911,7 @@ static LLVMValueRef visit_load_push_constant(struct 
nir_to_llvm_context *ctx,
 {
LLVMValueRef ptr;
 
-   LLVMValueRef indices[] = {ctx->i32zero, get_src(ctx, instr->src[0])};
-   ptr = LLVMBuildGEP(ctx->builder, ctx->push_constants, indices, 2, "");
+   ptr = build_gep0(ctx, ctx->push_constants, get_src(ctx, instr->src[0]));
ptr = cast_ptr(ctx, ptr, get_def_type(ctx, >dest.ssa));
 
return LLVMBuildLoad(ctx->builder, ptr, "");
@@ -3131,7 +3129,6 @@ static LLVMValueRef get_sampler_desc(struct 
nir_to_llvm_context *ctx,
unsigned type_size;
LLVMBuilderRef builder = ctx->builder;
LLVMTypeRef type;
-   LLVMValueRef indices[2];
LLVMValueRef index = NULL;
 
assert(deref->var->data.binding < layout->binding_count);
@@ -3175,9 +3172,8 @@ static LLVMValueRef get_sampler_desc(struct 
nir_to_llvm_context *ctx,
index = ctx->i32zero;
 
index = LLVMBuildMul(builder, index, LLVMConstInt(ctx->i32, stride / 
type_size, 0), "");
-   indices[0] = ctx->i32zero;
-   indices[1] = LLVMConstInt(ctx->i32, offset, 0);
-   list = LLVMBuildGEP(builder, list, indices, 2, "");
+
+   list = build_gep0(ctx, list, LLVMConstInt(ctx->i32, offset, 0));
list = LLVMBuildPointerCast(builder, list, const_array(type, 0), "");
 
return build_indexed_load_const(ctx, list, index);
-- 
2.7.4

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


[Mesa-dev] radv cleanup series

2016-12-07 Thread Dave Airlie
While working on spilling, geom shaders and compute queues, I've built
up a bunch of cleanups, so best to dequeue them early.

Dave.

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


Re: [Mesa-dev] [PATCH 00/84] Introduce gallium nine internal multithreading

2016-12-07 Thread Axel Davy

On 08/12/2016 00:38, Dieter Nützel wrote:

Am 07.12.2016 23:54, schrieb Axel Davy:

This patch adds internal multithreading to gallium nine.

The goal is to offload almost all gallium nine calls (and some other
work) to a worker thread.


Hello Axel,

really nice job!
'But' show us the 'numbers'...
...do you have some numbers of hand?

Thanks,
Dieter

The figures are in line with those shown in 
http://developer.amd.com/wordpress/media/2013/02/ATIMThread.pdf



I observe a 15% improvement on hl2 lost coast when configured to be cpu 
bound.


Other games benefit with various percentages (see for example 
http://www.gearsongallium.com/?p=3522 with an older patchset), but it 
seems to be around 10-20% for cpu limited scenarios.



If the game is not cpu limited, but gpu limited, there is no gain (as 
expected).



Axel

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


Re: [Mesa-dev] Potentially EOL ilo gallium driver

2016-12-07 Thread Edward O'Callaghan
Hi all,

So I'll get right to the crux of this; In summary the consensus would
then be to drop ilo?

If so, I am not sure of this communities procedure? However, if it helps
the patch is here:
https://cgit.freedesktop.org/~funfunctor/mesa/log/?h=eol-ilo

Kind Regards,
Edward.

On 12/07/2016 07:08 AM, Ilia Mirkin wrote:
> On Tue, Dec 6, 2016 at 3:00 PM, Rob Clark  wrote:
>> On Tue, Dec 6, 2016 at 2:11 PM, Jason Ekstrand  wrote:
>>> On Tue, Dec 6, 2016 at 8:39 AM, Rob Clark  wrote:

 On Tue, Dec 6, 2016 at 8:42 AM, Emil Velikov 
 wrote:
> On 6 December 2016 at 03:16, Edward O'Callaghan
>  wrote:
>> This patch is to potentially remove ourself from the maintaince
>> burden of the ilo driver that appears to now be essentially
>> unmaintained?
>>
>> I am not sure of our policy here or if there are too many
>> users so this patch is really only to gauge a response of
>> how folks feel?
>>
> Surely you want to CC the core/sole developer of the driver when
> considering its removal.
> Maybe mailman was "nice" and hid his email in the header ;-)
>
> Either way adding Chia-I Wu to the list.
>
> -Emil
> P.S. Not sure/sold how much of an actual burden the driver is, yet I
> don't make serious gallium infra changes.

 really hasn't been a problem for me..

 That said, it would be nice if someday someone wired this up to use
 glsl_to_nir path in gallium and re-used i965's nir backend.  I think
 that would make ilo somewhat more interesting..
>>>
>>>
>>> We had a bit of a chat about this on IRC and what I told Ilia there was that
>>> the more interesting thing to do, if someone really wanted to do Intel on
>>> gallium, would probably be to build a new driver based on ISL, blorp, the
>>> i965 compiler, NIR, and genxml.  We've made a pretty good driver-building
>>> toolbox.  Having an almost unmaintained driver that has it's own hand-rolled
>>> and inferrior compiler, surface layout, etc. isn't doing much good.
>>>
>>
>> yeah, reusing the other bits would be nice too, and hopefully would be
>> the long term goal if someone where to spend time on this.. I guess
>> I'd prefer a more incremental approach of converting parts one by one
>> if I were doing it myself.  It's kind of a moot point either way until
>> someone has time/motivation to spend on it.
>>
>> But I've no real objection to dropping ilo until then if others feel
>> strongly.. it's still there in git history so it can be resurrected if
>> someone wants to convert to reuse other i965 bits incrementally rather
>> than starting from scratch.
> 
> As mentioned on IRC, I think the real use-case that ilo could cover
> that i965/anv can't (easily) handle is acting as a gallium-nine
> backend. (I know someone's working on DX9 over vulkan, but that's
> hardly ready, and will never be available on gen6.)
> 
> However at this time, it's not sufficiently functional to handle
> gallium-nine, so I don't see any serious downside to dropping it.
> 
>   -ilia
> 



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


Re: [Mesa-dev] [PATCH v2 1/2] virgl: Fix a strict-aliasing violation in the encoder

2016-12-07 Thread Edward O'Callaghan


On 12/08/2016 02:53 AM, Emil Velikov wrote:
> On 6 December 2016 at 22:34, Edward O'Callaghan
>  wrote:
>> On 12/07/2016 12:36 AM, Emil Velikov wrote:
>>> On 6 December 2016 at 11:30, Edward O'Callaghan
>>>  wrote:
 As per the C spec, it is illegal to alias pointers to different
 types. This results in undefined behaviour after optimization
 passes, resulting in very subtle bugs that happen only on a
 full moon..

 Use a memcpy() as a well defined coercion between the double
 to uint64_t interpretations of the memory.

 V.2: Use static_assert() instead of assert().

>>> The lowercase static_assert is a c11 feature. You want to use the all
>>> caps version.
>>> See commit 23d1799f7dd5f8d1e8aa9f4efa6b1a4ed45faaa0
>>
>> Hi Emil,
>>
>> Why? I from that commit it seems only Android would have trouble however
>> virgl nor svga would want to be enabled on that platform?
>>
>> Or is there something else I probably missed?
>>
> If there's a valid reason to require X or Y one must clearly point it
> out, rather than jumping on bandwagons because it's cool/one can/etc.
> Forcing X and Y [without justification] is disrespectful towards
> everyone, even fellow developers. It also leads distro maintainers to
> think that upstream does not give a sh*t about issues they are faced
> with - old compilers, other.
> 
> There are [hundreds of] thousands people using mesa many of which with
> their own quirky requirements. Please consider that for future.
> Esp. when it's a trivial change as this ;-)

Emil, I understand all that and I had already sent a v3 with the
required amendment before I replied here. As I am not trying to
'force'/'disrespect' anyone or anything, I asked purely to gain a better
understanding of the reasoning behind requested change.

I don't take things on gospel, no matter how high up the developer is or
however trivial the change may be, as it is my change it is then my
responsibility to fully understand any variation to the change I am
proposing.

Kindest Regards,
Edward.

> 
> Thanks
> Emil
> 



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


[Mesa-dev] [PATCH] swr: [rasterizer common/core/jitter] fetch support for GL_FIXED

2016-12-07 Thread Tim Rowley
---
 .../drivers/swr/rasterizer/common/formats.cpp  | 104 ++---
 .../drivers/swr/rasterizer/common/formats.h|   7 +-
 .../drivers/swr/rasterizer/core/format_traits.h|  90 +-
 .../drivers/swr/rasterizer/jitter/fetch_jit.cpp|  12 +++
 src/gallium/drivers/swr/swr_screen.cpp |   9 ++
 5 files changed, 188 insertions(+), 34 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/common/formats.cpp 
b/src/gallium/drivers/swr/rasterizer/common/formats.cpp
index b3a95f2..aba4c3f 100644
--- a/src/gallium/drivers/swr/rasterizer/common/formats.cpp
+++ b/src/gallium/drivers/swr/rasterizer/common/formats.cpp
@@ -449,16 +449,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = {
 { 0.0f, 0.0f, 0.0f, 0.0f },
 1, 1
 },
-// padding (0x20)
+// R32G32B32A32_SFIXED (0x20)
 {
-nullptr,
-{ SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, 
SWR_TYPE_UNKNOWN },
-{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },
-0, 0, 0, false, false, false, false,
-{ false, false, false, false },
-{ 0.0f, 0.0f, 0.0f, 0.0f },
-1, 1
+"R32G32B32A32_SFIXED",
+{ SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_SFIXED },
+{ 0, 0, 0, 0x3f80 }, // Defaults for missing components
+{ 0, 1, 2, 3 }, // Swizzle
+{ 32, 32, 32, 32 }, // Bits per component
+128, // Bits per element
+16, // Bytes per element
+4, // Num components
+false, // isSRGB
+false, // isBC
+false, // isSubsampled
+false, // isLuminance
+{ false, false, false, false }, // Is normalized?
+{ 1.0f, 1.0f, 1.0f, 1.0f }, // To float scale factor
+1, // bcWidth
+1, // bcHeight
 },
+
 // padding (0x21)
 {
 nullptr,
@@ -979,16 +989,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = {
 { 0.0f, 0.0f, 0.0f, 0.0f },
 1, 1
 },
-// padding (0x50)
+// R32G32B32_SFIXED (0x50)
 {
-nullptr,
-{ SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, 
SWR_TYPE_UNKNOWN },
-{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },
-0, 0, 0, false, false, false, false,
-{ false, false, false, false },
-{ 0.0f, 0.0f, 0.0f, 0.0f },
-1, 1
+"R32G32B32_SFIXED",
+{ SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_UNKNOWN 
},
+{ 0, 0, 0, 0x3f80 }, // Defaults for missing components
+{ 0, 1, 2, 0 }, // Swizzle
+{ 32, 32, 32, 0 }, // Bits per component
+96, // Bits per element
+12, // Bytes per element
+3, // Num components
+false, // isSRGB
+false, // isBC
+false, // isSubsampled
+false, // isLuminance
+{ false, false, false, false }, // Is normalized?
+{ 1.0f, 1.0f, 1.0f, 0 }, // To float scale factor
+1, // bcWidth
+1, // bcHeight
 },
+
 // padding (0x51)
 {
 nullptr,
@@ -1969,16 +1989,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = {
 { 0.0f, 0.0f, 0.0f, 0.0f },
 1, 1
 },
-// padding (0xA0)
+// R32G32_SFIXED (0xA0)
 {
-nullptr,
-{ SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, 
SWR_TYPE_UNKNOWN },
-{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },
-0, 0, 0, false, false, false, false,
-{ false, false, false, false },
-{ 0.0f, 0.0f, 0.0f, 0.0f },
-1, 1
+"R32G32_SFIXED",
+{ SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN 
},
+{ 0, 0, 0, 0x3f80 }, // Defaults for missing components
+{ 0, 1, 0, 0 }, // Swizzle
+{ 32, 32, 0, 0 }, // Bits per component
+64, // Bits per element
+8, // Bytes per element
+2, // Num components
+false, // isSRGB
+false, // isBC
+false, // isSubsampled
+false, // isLuminance
+{ false, false, false, false }, // Is normalized?
+{ 1.0f, 1.0f, 0, 0 }, // To float scale factor
+1, // bcWidth
+1, // bcHeight
 },
+
 // padding (0xA1)
 {
 nullptr,
@@ -5909,16 +5939,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = {
 1, // bcHeight
 },
 
-// padding (0x1B2)
+// R32_SFIXED (0x1B2)
 {
-nullptr,
-{ SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, 
SWR_TYPE_UNKNOWN },
-{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 },
-0, 0, 0, false, false, false, false,
-{ false, false, false, false },
-{ 0.0f, 0.0f, 0.0f, 0.0f },
-1, 1
+"R32_SFIXED",
+{ SWR_TYPE_SFIXED, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, 
SWR_TYPE_UNKNOWN },
+{ 0, 0, 0, 0x3f80 }, // Defaults for missing components
+{ 0, 0, 0, 0 }, // Swizzle
+{ 32, 0, 0, 0 }, // Bits per component
+32, // Bits per element
+4, // Bytes per element
+

[Mesa-dev] [PATCH] swr: [rasterizer core/memory] Finish R24_UNORM_X8_TYPELESS for AVX512

2016-12-07 Thread Tim Rowley
This one-off specialization was missed.
---
 src/gallium/drivers/swr/rasterizer/core/backend.h  |  4 +-
 .../drivers/swr/rasterizer/memory/StoreTile.h  | 46 +++---
 2 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/core/backend.h 
b/src/gallium/drivers/swr/rasterizer/core/backend.h
index 706b372..48cfce2 100644
--- a/src/gallium/drivers/swr/rasterizer/core/backend.h
+++ b/src/gallium/drivers/swr/rasterizer/core/backend.h
@@ -463,7 +463,7 @@ inline void SetupBarycentricCoeffs(BarycentricCoeffs 
*coeffs, const SWR_TRIANGLE
 
 inline void SetupRenderBuffers(uint8_t *pColorBuffer[SWR_NUM_RENDERTARGETS], 
uint8_t **pDepthBuffer, uint8_t **pStencilBuffer, uint32_t colorBufferCount, 
RenderOutputBuffers )
 {
-SWR_ASSERT(colorBufferCount <= SWR_NUM_RENDERTARGETS);
+assert(colorBufferCount <= SWR_NUM_RENDERTARGETS);
 
 if (pColorBuffer)
 {
@@ -754,8 +754,6 @@ INLINE void OutputMerger(SWR_PS_CONTEXT , 
uint8_t* ()[SWR_N
 INLINE void OutputMerger(SWR_PS_CONTEXT , uint8_t* 
()[SWR_NUM_RENDERTARGETS], uint32_t sample, const SWR_BLEND_STATE 
*pBlendState,
 const PFN_BLEND_JIT_FUNC()[SWR_NUM_RENDERTARGETS], simdscalar 
, simdscalar depthPassMask, const uint32_t NumRT, bool 
useAlternateOffset)
 {
-assert(sample == 0); // will need up upate Raster Tile Color Offsets to 
support more than single sample here..
-
 // type safety guaranteed from template instantiation in 
BEChooser<>::GetFunc
 uint32_t rasterTileColorOffset = RasterTileColorOffset(sample);
 
diff --git a/src/gallium/drivers/swr/rasterizer/memory/StoreTile.h 
b/src/gallium/drivers/swr/rasterizer/memory/StoreTile.h
index 558f048..4fa6683 100644
--- a/src/gallium/drivers/swr/rasterizer/memory/StoreTile.h
+++ b/src/gallium/drivers/swr/rasterizer/memory/StoreTile.h
@@ -545,38 +545,38 @@ struct ConvertPixelsSOAtoAOS
 INLINE static void Convert(const uint8_t* pSrc, uint8_t* 
()[NumDests])
 {
 #if USE_8x2_TILE_BACKEND
-static const uint32_t MAX_RASTER_TILE_BYTES = 16 * 4; // 16 pixels * 4 
bytes per pixel
+simd16scalar comp = _simd16_load_ps(reinterpret_cast(pSrc));
 
-OSALIGNSIMD16(uint8_t) soaTile[MAX_RASTER_TILE_BYTES];
-OSALIGNSIMD16(uint8_t) aosTile[MAX_RASTER_TILE_BYTES];
+// clamp
+const simd16scalar zero = _simd16_setzero_ps();
+const simd16scalar ones = _simd16_set1_ps(1.0f);
 
-// Convert from SrcFormat --> DstFormat
-simd16vector src;
-LoadSOA(pSrc, src);
-StoreSOA(src, soaTile);
+comp = _simd16_max_ps(comp, zero);
+comp = _simd16_min_ps(comp, ones);
 
-// Convert from SOA --> AOS
-FormatTraits::TransposeT::Transpose_16(soaTile, aosTile);
-
-// Store data into destination but don't overwrite the X8 bits
-// Each 4-pixel row is 16-bytes
+// normalize
+comp = _simd16_mul_ps(comp, 
_simd16_set1_ps(FormatTraits::fromFloat(0)));
 
-simdscalari loadlo = _simd_load_si(reinterpret_cast(aosTile));
-simdscalari loadhi = _simd_load_si(reinterpret_cast(aosTile + sizeof(simdscalari)));
+simd16scalari temp = _simd16_cvtps_epi32(comp);
 
-simdscalari templo = _simd_unpacklo_epi64(loadlo, loadhi);
-simdscalari temphi = _simd_unpackhi_epi64(loadlo, loadhi);
+// swizzle
+temp = _simd16_permute_epi32(temp, _simd16_set_epi32(15, 14, 11, 10, 
13, 12, 9, 8, 7, 6, 3, 2, 5, 4, 1, 0));
 
+// merge/store data into destination but don't overwrite the X8 bits
 simdscalari destlo = _simd_loadu2_si(reinterpret_cast<__m128i 
*>(ppDsts[1]), reinterpret_cast<__m128i *>(ppDsts[0]));
 simdscalari desthi = _simd_loadu2_si(reinterpret_cast<__m128i 
*>(ppDsts[3]), reinterpret_cast<__m128i *>(ppDsts[2]));
 
-simdscalari mask = _simd_set1_epi32(0x00FF);
+simd16scalari dest = _simd16_setzero_si();
+
+dest = _simd16_insert_si(dest, destlo, 0);
+dest = _simd16_insert_si(dest, desthi, 1);
+
+simd16scalari mask = _simd16_set1_epi32(0x00FF);
 
-destlo = _simd_or_si(_simd_andnot_si(mask, destlo), _simd_and_si(mask, 
templo));
-desthi = _simd_or_si(_simd_andnot_si(mask, desthi), _simd_and_si(mask, 
templo));
+dest = _simd16_or_si(_simd16_andnot_si(mask, dest), 
_simd16_and_si(mask, temp));
 
-_simd_storeu2_si(reinterpret_cast<__m128i *>(ppDsts[1]), 
reinterpret_cast<__m128i *>(ppDsts[0]), destlo);
-_simd_storeu2_si(reinterpret_cast<__m128i *>(ppDsts[3]), 
reinterpret_cast<__m128i *>(ppDsts[2]), desthi);
+_simd_storeu2_si(reinterpret_cast<__m128i *>(ppDsts[1]), 
reinterpret_cast<__m128i *>(ppDsts[0]), _simd16_extract_si(dest, 0));
+_simd_storeu2_si(reinterpret_cast<__m128i *>(ppDsts[3]), 
reinterpret_cast<__m128i *>(ppDsts[2]), _simd16_extract_si(dest, 1));
 #else
 static const uint32_t MAX_RASTER_TILE_BYTES = 128; // 8 

Re: [Mesa-dev] [PATCH 00/84] Introduce gallium nine internal multithreading

2016-12-07 Thread Dieter Nützel

Am 07.12.2016 23:54, schrieb Axel Davy:

This patch adds internal multithreading to gallium nine.

The goal is to offload almost all gallium nine calls (and some other
work) to a worker thread.


Hello Axel,

really nice job!
'But' show us the 'numbers'...
...do you have some numbers of hand?

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


[Mesa-dev] [PATCH 07/36] st/nine: Remove unused ff.changed.group

2016-12-07 Thread Axel Davy
It was unused.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_state.h  | 1 -
 src/gallium/state_trackers/nine/stateblock9.c | 5 -
 2 files changed, 6 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_state.h 
b/src/gallium/state_trackers/nine/nine_state.h
index 714f1a9..bde02e3 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -209,7 +209,6 @@ struct nine_state
 
 struct {
 struct {
-uint32_t group;
 uint32_t tex_stage[NINE_MAX_TEXTURE_STAGES][(NINED3DTSS_COUNT + 
31) / 32];
 uint32_t transform[(NINED3DTS_COUNT + 31) / 32];
 } changed;
diff --git a/src/gallium/state_trackers/nine/stateblock9.c 
b/src/gallium/state_trackers/nine/stateblock9.c
index 75754df..16e60ef 100644
--- a/src/gallium/state_trackers/nine/stateblock9.c
+++ b/src/gallium/state_trackers/nine/stateblock9.c
@@ -293,8 +293,6 @@ nine_state_copy_common(struct NineDevice9 *device,
 WARN_ONCE("Fixed function state not handled properly by StateBlocks.\n");
 
 /* Fixed function state. */
-if (apply)
-dst->ff.changed.group |= src->ff.changed.group;
 
 if (mask->changed.group & NINE_STATE_FF_MATERIAL)
 dst->ff.material = src->ff.material;
@@ -480,9 +478,6 @@ nine_state_copy_common_all(struct NineDevice9 *device,
 WARN_ONCE("Fixed function state not handled properly by StateBlocks.\n");
 
 /* Fixed function state. */
-if (apply)
-dst->ff.changed.group = src->ff.changed.group;
-
 dst->ff.material = src->ff.material;
 
 memcpy(dst->ff.tex_stage, src->ff.tex_stage, sizeof(dst->ff.tex_stage));
-- 
2.10.2

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


[Mesa-dev] [PATCH 12/36] st/nine: Capture texturestage states in pixel stateblocks

2016-12-07 Thread Axel Davy
pixels stateblocks need to capture these.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/device9.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/device9.c 
b/src/gallium/state_trackers/nine/device9.c
index 5b4d2ae..8b03e9b 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -2524,7 +2524,6 @@ NineDevice9_CreateStateBlock( struct NineDevice9 *This,
   NINE_STATE_FF_OTHER | NINE_STATE_FF_PSSTAGES | NINE_STATE_PS_CONST |
   NINE_STATE_FB | NINE_STATE_DSA | NINE_STATE_MULTISAMPLE |
   NINE_STATE_RASTERIZER | NINE_STATE_STENCIL_REF;
-   /* TODO: texture/sampler state */
memcpy(dst->changed.rs,
   nine_render_states_pixel, sizeof(dst->changed.rs));
nine_ranges_insert(>changed.ps_const_f, 0, This->max_ps_const_f,
@@ -2533,6 +2532,10 @@ NineDevice9_CreateStateBlock( struct NineDevice9 *This,
dst->changed.ps_const_b = 0x;
for (s = 0; s < NINE_MAX_SAMPLERS; ++s)
dst->changed.sampler[s] |= 0x1ffe;
+   for (s = 0; s < NINE_MAX_TEXTURE_STAGES; ++s) {
+   dst->ff.changed.tex_stage[s][0] |= 0x;
+   dst->ff.changed.tex_stage[s][1] |= 0x;
+   }
 }
 if (Type == D3DSBT_ALL) {
dst->changed.group |=
-- 
2.10.2

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


[Mesa-dev] [PATCH 26/36] st/nine: Fix specular enable for alpha

2016-12-07 Thread Axel Davy
Apparently specular enable doesn't affect
the alpha channel.

Fixes https://github.com/iXit/Mesa-3D/issues/253

Behaviour comfirmed looking in wine sources.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_ff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c 
b/src/gallium/state_trackers/nine/nine_ff.c
index f4ec6aa..7ff7331 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -1528,7 +1528,7 @@ nine_ff_build_ps(struct NineDevice9 *device, struct 
nine_ff_ps_key *key)
 }
 
 if (key->specular)
-ureg_ADD(ureg, ps.rCur, ps.rCurSrc, ps.vC[1]);
+ureg_ADD(ureg, ureg_writemask(ps.rCur, TGSI_WRITEMASK_XYZ), 
ps.rCurSrc, ps.vC[1]);
 
 /* Fog.
  */
-- 
2.10.2

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


[Mesa-dev] [PATCH 21/36] st/nine: Fix a leak in Swapchain dtor

2016-12-07 Thread Axel Davy
Count properly the number of backbuffers,
and use the new info to release the correct
number of buffers

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/swapchain9.c | 31 ++--
 src/gallium/state_trackers/nine/swapchain9.h |  1 +
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/gallium/state_trackers/nine/swapchain9.c 
b/src/gallium/state_trackers/nine/swapchain9.c
index f571416..431966d 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -206,9 +206,7 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
 /* When we have flip behaviour, d3d9 expects we get back the screen buffer 
when we flip.
  * Here we don't get back the initial content of the screen. To emulate 
the behaviour
  * we allocate an additional buffer */
-oldBufferCount = This->params.BackBufferCount ?
- (This->params.BackBufferCount +
-  (This->params.SwapEffect != D3DSWAPEFFECT_COPY)) : 0;
+oldBufferCount = This->num_back_buffers;
 newBufferCount = pParams->BackBufferCount +
  (pParams->SwapEffect != D3DSWAPEFFECT_COPY);
 
@@ -295,6 +293,7 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
 This->present_handles[i] = NULL;
 }
 }
+This->num_back_buffers = newBufferCount;
 
 for (i = 0; i < newBufferCount; ++i) {
 tmplt.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
@@ -498,13 +497,13 @@ NineSwapChain9_dtor( struct NineSwapChain9 *This )
 if (This->pool)
 _mesa_threadpool_destroy(This, This->pool);
 
-if (This->buffers[0]) {
-for (i = 0; i < This->params.BackBufferCount; i++) {
+for (i = 0; i < This->num_back_buffers; i++) {
+if (This->buffers[i])
 NineUnknown_Release(NineUnknown(This->buffers[i]));
+if (This->present_handles[i])
 ID3DPresent_DestroyD3DWindowBuffer(This->present, 
This->present_handles[i]);
-if (This->present_buffers[i])
-pipe_resource_reference(&(This->present_buffers[i]), NULL);
-}
+if (This->present_buffers[i])
+pipe_resource_reference(&(This->present_buffers[i]), NULL);
 }
 if (This->zsbuf)
 NineUnknown_Unbind(NineUnknown(This->zsbuf));
@@ -806,32 +805,32 @@ NineSwapChain9_Present( struct NineSwapChain9 *This,
 case D3DSWAPEFFECT_DISCARD:
 /* rotate the queue */
 pipe_resource_reference(, This->buffers[0]->base.resource);
-for (i = 1; i <= This->params.BackBufferCount; i++) {
+for (i = 1; i < This->num_back_buffers; i++) {
 NineSurface9_SetResourceResize(This->buffers[i - 1],

This->buffers[i]->base.resource);
 }
 NineSurface9_SetResourceResize(
-This->buffers[This->params.BackBufferCount], res);
+This->buffers[This->num_back_buffers - 1], res);
 pipe_resource_reference(, NULL);
 
 if (This->present_buffers[0]) {
 pipe_resource_reference(, This->present_buffers[0]);
-for (i = 1; i <= This->params.BackBufferCount; i++)
+for (i = 1; i < This->num_back_buffers; i++)
 pipe_resource_reference(&(This->present_buffers[i-1]), 
This->present_buffers[i]);
-
pipe_resource_reference(&(This->present_buffers[This->params.BackBufferCount]), 
res);
+
pipe_resource_reference(&(This->present_buffers[This->num_back_buffers - 1]), 
res);
 pipe_resource_reference(, NULL);
 }
 
 handle_temp = This->present_handles[0];
-for (i = 1; i <= This->params.BackBufferCount; i++) {
+for (i = 1; i < This->num_back_buffers; i++) {
 This->present_handles[i-1] = This->present_handles[i];
 }
-This->present_handles[This->params.BackBufferCount] = handle_temp;
+This->present_handles[This->num_back_buffers - 1] = handle_temp;
 task_temp = This->tasks[0];
-for (i = 1; i <= This->params.BackBufferCount; i++) {
+for (i = 1; i < This->num_back_buffers; i++) {
 This->tasks[i-1] = This->tasks[i];
 }
-This->tasks[This->params.BackBufferCount] = task_temp;
+This->tasks[This->num_back_buffers - 1] = task_temp;
 break;
 
 case D3DSWAPEFFECT_COPY:
diff --git a/src/gallium/state_trackers/nine/swapchain9.h 
b/src/gallium/state_trackers/nine/swapchain9.h
index 551c744..9f33d17 100644
--- a/src/gallium/state_trackers/nine/swapchain9.h
+++ b/src/gallium/state_trackers/nine/swapchain9.h
@@ -53,6 +53,7 @@ struct NineSwapChain9
 D3DDISPLAYMODEEX *mode;
 struct d3dadapter9_context *actx;
 BOOL implicit;
+unsigned num_back_buffers;
 
 /* 

[Mesa-dev] [PATCH 22/36] st/nine: Rework buffer presentation path

2016-12-07 Thread Axel Davy
Use the new API for DISCARD.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/swapchain9.c | 180 ---
 1 file changed, 132 insertions(+), 48 deletions(-)

diff --git a/src/gallium/state_trackers/nine/swapchain9.c 
b/src/gallium/state_trackers/nine/swapchain9.c
index 431966d..79530f5 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -67,6 +67,15 @@ NineSwapChain9_ctor( struct NineSwapChain9 *This,
 This->mode = NULL;
 
 ID3DPresent_AddRef(pPresent);
+if (!This->actx->thread_submit &&
+This->base.device->minor_version_num > 2) {
+D3DPRESENT_PARAMETERS2 params2;
+
+memset(, 0, sizeof(D3DPRESENT_PARAMETERS2));
+params2.AllowDISCARDDelayedRelease = TRUE;
+params2.TearFreeDISCARD = FALSE;
+ID3DPresent_SetPresentParameters2(pPresent, );
+}
 
 if (!pPresentationParameters->hDeviceWindow)
 pPresentationParameters->hDeviceWindow = hFocusWindow;
@@ -114,6 +123,10 @@ D3DWindowBuffer_create(struct NineSwapChain9 *This,
 return ret;
 }
 
+static int
+NineSwapChain9_GetBackBufferCountForParams( struct NineSwapChain9 *This,
+D3DPRESENT_PARAMETERS *pParams );
+
 HRESULT
 NineSwapChain9_Resize( struct NineSwapChain9 *This,
D3DPRESENT_PARAMETERS *pParams,
@@ -203,12 +216,8 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
 if (hr != D3D_OK)
 return hr;
 
-/* When we have flip behaviour, d3d9 expects we get back the screen buffer 
when we flip.
- * Here we don't get back the initial content of the screen. To emulate 
the behaviour
- * we allocate an additional buffer */
 oldBufferCount = This->num_back_buffers;
-newBufferCount = pParams->BackBufferCount +
- (pParams->SwapEffect != D3DSWAPEFFECT_COPY);
+newBufferCount = NineSwapChain9_GetBackBufferCountForParams(This, pParams);
 
 multisample_type = pParams->MultiSampleType;
 
@@ -799,58 +808,93 @@ NineSwapChain9_Present( struct NineSwapChain9 *This,
 if (hr == D3DERR_WASSTILLDRAWING)
 return hr;
 
-switch (This->params.SwapEffect) {
-case D3DSWAPEFFECT_FLIP:
-UNTESTED(4);
-case D3DSWAPEFFECT_DISCARD:
-/* rotate the queue */
-pipe_resource_reference(, This->buffers[0]->base.resource);
-for (i = 1; i < This->num_back_buffers; i++) {
-NineSurface9_SetResourceResize(This->buffers[i - 1],
-   
This->buffers[i]->base.resource);
-}
-NineSurface9_SetResourceResize(
-This->buffers[This->num_back_buffers - 1], res);
-pipe_resource_reference(, NULL);
+if (This->base.device->minor_version_num > 2 &&
+This->params.SwapEffect == D3DSWAPEFFECT_DISCARD &&
+This->params.PresentationInterval == D3DPRESENT_INTERVAL_IMMEDIATE &&
+!This->actx->thread_submit) {
+int next_buffer = -1;
 
-if (This->present_buffers[0]) {
-pipe_resource_reference(, This->present_buffers[0]);
-for (i = 1; i < This->num_back_buffers; i++)
-pipe_resource_reference(&(This->present_buffers[i-1]), 
This->present_buffers[i]);
-
pipe_resource_reference(&(This->present_buffers[This->num_back_buffers - 1]), 
res);
-pipe_resource_reference(, NULL);
-}
-
-handle_temp = This->present_handles[0];
+while (next_buffer == -1) {
+/* Find a free backbuffer */
 for (i = 1; i < This->num_back_buffers; i++) {
-This->present_handles[i-1] = This->present_handles[i];
+if (ID3DPresent_IsBufferReleased(This->present, 
This->present_handles[i])) {
+DBG("Found buffer released: %d\n", i);
+next_buffer = i;
+break;
+}
 }
-This->present_handles[This->num_back_buffers - 1] = handle_temp;
-task_temp = This->tasks[0];
-for (i = 1; i < This->num_back_buffers; i++) {
-This->tasks[i-1] = This->tasks[i];
+if (next_buffer == -1) {
+DBG("Found no buffer released. Waiting for event\n");
+ID3DPresent_WaitBufferReleaseEvent(This->present);
 }
-This->tasks[This->num_back_buffers - 1] = task_temp;
-break;
+}
+/* Switch with the released buffer */
+pipe_resource_reference(, This->buffers[0]->base.resource);
+NineSurface9_SetResourceResize(
+This->buffers[0], This->buffers[next_buffer]->base.resource);
+NineSurface9_SetResourceResize(
+This->buffers[next_buffer], res);
+pipe_resource_reference(, NULL);
+
+if (This->present_buffers[0]) {
+

[Mesa-dev] [PATCH 32/36] st/nine: Remove useless code in ff ps

2016-12-07 Thread Axel Davy
Current is already initialized to Diffuse.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_ff.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c 
b/src/gallium/state_trackers/nine/nine_ff.c
index 7a09986..c3245a3 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -1375,11 +1375,6 @@ nine_ff_build_ps(struct NineDevice9 *device, struct 
nine_ff_ps_key *key)
 
 oCol = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 0);
 
-if (key->ts[0].colorop == D3DTOP_DISABLE &&
-key->ts[0].alphaop == D3DTOP_DISABLE)
-ureg_MOV(ureg, ps.rCur, ps.vC[0]);
-/* Or is it undefined then ? */
-
 /* Run stages.
  */
 for (s = 0; s < 8; ++s) {
-- 
2.10.2

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


[Mesa-dev] [PATCH 10/36] st/nine: Add some debug info in stateblocks

2016-12-07 Thread Axel Davy
This is useful to check what is exactly recorded.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/stateblock9.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/state_trackers/nine/stateblock9.c 
b/src/gallium/state_trackers/nine/stateblock9.c
index a2b281e..fbbd41b 100644
--- a/src/gallium/state_trackers/nine/stateblock9.c
+++ b/src/gallium/state_trackers/nine/stateblock9.c
@@ -119,6 +119,7 @@ nine_state_copy_common(struct NineDevice9 *device,
 {
 unsigned i, s;
 
+DBG("apply:%d changed.group: %x\n", (int)apply, (int)mask->changed.group );
 if (apply)
dst->changed.group |= mask->changed.group;
 
@@ -225,6 +226,7 @@ nine_state_copy_common(struct NineDevice9 *device,
 const int r = ffs(m) - 1;
 m &= ~(1 << r);
 dst->rs[i * 32 + r] = src->rs[i * 32 + r];
+DBG("State %d %s = %d\n", i * 32 + r, nine_d3drs_to_string(i * 32 
+ r), (int)src->rs[i * 32 + r]);
 dst->rs_advertised[i * 32 + r] = src->rs_advertised[i * 32 + r];
 }
 }
@@ -232,6 +234,7 @@ nine_state_copy_common(struct NineDevice9 *device,
 
 /* Clip planes. */
 if (mask->changed.ucp) {
+DBG("ucp: %x\n", mask->changed.ucp);
 for (i = 0; i < PIPE_MAX_CLIP_PLANES; ++i)
 if (mask->changed.ucp & (1 << i))
 memcpy(dst->clip.ucp[i],
@@ -248,6 +251,7 @@ nine_state_copy_common(struct NineDevice9 *device,
 memcpy(>samp_advertised[s], >samp_advertised[s], 
sizeof(dst->samp_advertised[s]));
 } else {
 uint32_t m = mask->changed.sampler[s];
+DBG("samp %d: changed = %x\n", i, (int)m);
 while (m) {
 const int i = ffs(m) - 1;
 m &= ~(1 << i);
@@ -266,6 +270,7 @@ nine_state_copy_common(struct NineDevice9 *device,
 
 /* Vertex streams. */
 if (mask->changed.vtxbuf | mask->changed.stream_freq) {
+DBG("vtxbuf/stream_freq: %x/%x\n", mask->changed.vtxbuf, 
mask->changed.stream_freq);
 uint32_t m = mask->changed.vtxbuf | mask->changed.stream_freq;
 for (i = 0; m; ++i, m >>= 1) {
 if (mask->changed.vtxbuf & (1 << i)) {
-- 
2.10.2

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


[Mesa-dev] [PATCH 27/36] st/nine: Fix ff COLOR0 w component computation

2016-12-07 Thread Axel Davy
The computation was wrong. COLOR0's last component
should be equal to the material diffuse w component.

The behaviour was checked with a test app on Windows.
Wine has the same behaviour.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_ff.c | 31 ++-
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c 
b/src/gallium/state_trackers/nine/nine_ff.c
index 7ff7331..8b6f442 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -206,7 +206,7 @@ static void nine_ureg_tgsi_dump(struct ureg_program *ureg, 
boolean override)
  * CONST[12..15] D3DTS_VIEW^(-1)
  * CONST[16..18] Normal matrix
  *
- * CONST[19]  MATERIAL.Emissive + Material.Ambient * RS.Ambient
+ * CONST[19].xyz  MATERIAL.Emissive + Material.Ambient * RS.Ambient
  * CONST[20]  MATERIAL.Diffuse
  * CONST[21]  MATERIAL.Ambient
  * CONST[22]  MATERIAL.Specular
@@ -914,11 +914,6 @@ nine_ff_build_vs(struct NineDevice9 *device, struct 
vs_build_ctx *vs)
 ureg_fixup_label(ureg, label[loop_label], 
ureg_get_instruction_number(ureg));
 ureg_ENDLOOP(ureg, [loop_label]);
 
-/* Set alpha factors of illumination to 1.0 for the multiplications. */
-rD.WriteMask = TGSI_WRITEMASK_W; rD.Saturate = 0;
-rA.WriteMask = TGSI_WRITEMASK_W; rA.Saturate = 0;
-ureg_MOV(ureg, rD, ureg_imm1f(ureg, 1.0f));
-
 /* Apply to material:
  *
  * oCol[0] = (material.emissive + material.ambient * rs.ambient) +
@@ -926,16 +921,15 @@ nine_ff_build_vs(struct NineDevice9 *device, struct 
vs_build_ctx *vs)
  *   material.diffuse * diffuse +
  * oCol[1] = material.specular * specular;
  */
-if (key->mtl_emissive == 0 && key->mtl_ambient == 0) {
-ureg_MOV(ureg, rA, ureg_imm1f(ureg, 1.0f));
-ureg_MAD(ureg, tmp, ureg_src(rA), vs->mtlA, _CONST(19));
-} else {
+if (key->mtl_emissive == 0 && key->mtl_ambient == 0)
+ureg_MAD(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_XYZ), 
ureg_src(rA), vs->mtlA, _CONST(19));
+else {
 ureg_ADD(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_XYZ), 
ureg_src(rA), _CONST(25));
 ureg_MAD(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_XYZ), vs->mtlA, 
ureg_src(tmp), vs->mtlE);
-ureg_ADD(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_W  ), vs->mtlA, 
vs->mtlE);
 }
 
-ureg_MAD(ureg, oCol[0], ureg_src(rD), vs->mtlD, ureg_src(tmp));
+ureg_MAD(ureg, ureg_writemask(oCol[0], TGSI_WRITEMASK_XYZ), 
ureg_src(rD), vs->mtlD, ureg_src(tmp));
+ureg_MOV(ureg, ureg_writemask(oCol[0], TGSI_WRITEMASK_W), vs->mtlD);
 ureg_MUL(ureg, oCol[1], ureg_src(rS), vs->mtlS);
 ureg_release_temporary(ureg, rAtt);
 ureg_release_temporary(ureg, rHit);
@@ -949,15 +943,11 @@ nine_ff_build_vs(struct NineDevice9 *device, struct 
vs_build_ctx *vs)
 } else
 /* COLOR */
 if (key->darkness) {
-if (key->mtl_emissive == 0 && key->mtl_ambient == 0) {
-ureg_MAD(ureg, oCol[0], vs->mtlD, ureg_imm4f(ureg, 0.0f, 0.0f, 
0.0f, 1.0f), _CONST(19));
-} else {
-struct ureg_dst tmp = ureg_DECL_temporary(ureg);
+if (key->mtl_emissive == 0 && key->mtl_ambient == 0)
+ureg_MOV(ureg, ureg_writemask(oCol[0], TGSI_WRITEMASK_XYZ), 
_CONST(19));
+else
 ureg_MAD(ureg, ureg_writemask(oCol[0], TGSI_WRITEMASK_XYZ), 
vs->mtlA, _CONST(25), vs->mtlE);
-ureg_ADD(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_W), 
vs->mtlA, vs->mtlE);
-ureg_ADD(ureg, ureg_writemask(oCol[0], TGSI_WRITEMASK_W), 
vs->mtlD, _W(tmp));
-ureg_release_temporary(ureg, tmp);
-}
+ureg_MOV(ureg, ureg_writemask(oCol[0], TGSI_WRITEMASK_W), vs->mtlD);
 ureg_MOV(ureg, oCol[1], ureg_imm1f(ureg, 0.0f));
 } else {
 ureg_MOV(ureg, oCol[0], vs->aCol[0]);
@@ -1891,7 +1881,6 @@ nine_ff_load_lights(struct NineDevice9 *device)
 dst[19].x = dst[25].x * mtl->Ambient.r + mtl->Emissive.r;
 dst[19].y = dst[25].y * mtl->Ambient.g + mtl->Emissive.g;
 dst[19].z = dst[25].z * mtl->Ambient.b + mtl->Emissive.b;
-dst[19].w = mtl->Ambient.a + mtl->Emissive.a;
 }
 
 if (!(state->changed.group & NINE_STATE_FF_LIGHTING))
-- 
2.10.2

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


[Mesa-dev] [PATCH 34/36] st/nine: Convert redundant check to assert in ff ps

2016-12-07 Thread Axel Davy
We disable the alpha stage if the color stage is disabled.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_ff.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c 
b/src/gallium/state_trackers/nine/nine_ff.c
index 294fbc8..f30a988 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -1385,9 +1385,10 @@ nine_ff_build_ps(struct NineDevice9 *device, struct 
nine_ff_ps_key *key)
 struct ureg_dst dst;
 struct ureg_src arg[3];
 
-if (key->ts[s].colorop == D3DTOP_DISABLE &&
-key->ts[s].alphaop == D3DTOP_DISABLE)
+if (key->ts[s].colorop == D3DTOP_DISABLE) {
+assert (key->ts[s].alphaop == D3DTOP_DISABLE);
 continue;
+}
 ps.stage.index = s;
 
 DBG("STAGE[%u]: colorop=%s alphaop=%s\n", s,
-- 
2.10.2

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


[Mesa-dev] [PATCH 29/36] st/nine: Fix check for ff specular

2016-12-07 Thread Axel Davy
Fix the check for computing ff specular.

This seems to match the opengl behavior,
and give the correct output on windows.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_ff.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c 
b/src/gallium/state_trackers/nine/nine_ff.c
index a1eb378..ecb1dd8 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -883,9 +883,15 @@ nine_ff_build_vs(struct NineDevice9 *device, struct 
vs_build_ctx *vs)
 ureg_SUB(ureg, rMid, ureg_src(rHit), ureg_imm3f(ureg, 0.0f, 
0.0f, 1.0f));
 }
 ureg_normalize3(ureg, rMid, ureg_src(rMid));
+ureg_DP3(ureg, ureg_saturate(tmp_x), vs->aNrm, ureg_src(rHit));
 ureg_DP3(ureg, ureg_saturate(tmp_y), vs->aNrm, ureg_src(rMid));
-ureg_IF(ureg, _Y(tmp), [l++]);
+ureg_MUL(ureg, tmp_z, _X(tmp), _Y(tmp));
+/* Tests show that specular is computed only if 
(dp3(normal,hitDir) > 0).
+ * For front facing, it is more restrictive than test 
(dp3(normal,mid) > 0).
+ * No tests were made for backfacing, so add the two conditions */
+ureg_IF(ureg, _Z(tmp), [l++]);
 {
+ureg_DP3(ureg, ureg_saturate(tmp_y), vs->aNrm, ureg_src(rMid));
 ureg_POW(ureg, tmp_y, _Y(tmp), mtlP);
 ureg_MUL(ureg, tmp_y, _W(rAtt), _Y(tmp)); /* power factor * 
att */
 ureg_MAD(ureg, rS, cLColS, _Y(tmp), ureg_src(rS)); /* 
accumulate specular */
@@ -893,7 +899,6 @@ nine_ff_build_vs(struct NineDevice9 *device, struct 
vs_build_ctx *vs)
 ureg_fixup_label(ureg, label[l-1], 
ureg_get_instruction_number(ureg));
 ureg_ENDIF(ureg);
 
-ureg_DP3(ureg, ureg_saturate(tmp_x), vs->aNrm, ureg_src(rHit));
 ureg_MUL(ureg, tmp_x, _W(rAtt), _X(tmp)); /* dp3(normal,hitDir) * 
att */
 ureg_MAD(ureg, rD, cLColD, _X(tmp), ureg_src(rD)); /* accumulate 
diffuse */
 }
-- 
2.10.2

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


[Mesa-dev] [PATCH 36/36] st/nine: Implement WFOG properly

2016-12-07 Thread Axel Davy
We were advertising support for WFOG (like all win drivers),
but we weren't implementing it.
This patch implements the behaviour. See comments.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_ff.c | 42 +--
 1 file changed, 35 insertions(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c 
b/src/gallium/state_trackers/nine/nine_ff.c
index 283a3cd..9b6893d 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -111,8 +111,9 @@ struct nine_ff_ps_key
 uint32_t projected : 16;
 uint32_t fog : 1; /* for vFog coming from VS */
 uint32_t fog_mode : 2;
+uint32_t fog_source : 1; /* 0: Z, 1: W */
 uint32_t specular : 1;
-uint32_t pad1 : 12; /* 9 32-bit words with this */
+uint32_t pad1 : 11; /* 9 32-bit words with this */
 uint8_t colorarg_b4[3];
 uint8_t colorarg_b5[3];
 uint8_t alphaarg_b4[3]; /* 11 32-bit words plus a byte */
@@ -1497,6 +1498,7 @@ nine_ff_build_ps(struct NineDevice9 *device, struct 
nine_ff_ps_key *key)
 /* Fog.
  */
 if (key->fog_mode) {
+struct ureg_dst rFog = ureg_writemask(ps.rTmp, TGSI_WRITEMASK_X);
 struct ureg_src vPos;
 if (device->screen->get_param(device->screen,
   PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL)) {
@@ -1506,20 +1508,35 @@ nine_ff_build_ps(struct NineDevice9 *device, struct 
nine_ff_ps_key *key)
   TGSI_INTERPOLATE_LINEAR);
 }
 
-struct ureg_dst rFog = ureg_writemask(ps.rTmp, TGSI_WRITEMASK_X);
+/* Source is either W or Z.
+ * When we use vs ff,
+ * Z is when an orthogonal projection matrix is detected,
+ * W (WFOG) else.
+ * Z is used for programmable vs.
+ * Note: Tests indicate that the projection matrix coefficients do
+ * actually affect pixel fog (and not vertex fog) when vs ff is used,
+ * which justifies taking the position's w instead of taking the z 
coordinate
+ * before the projection in the vs shader.
+ */
+if (!key->fog_source)
+ureg_MOV(ureg, rFog, _(vPos));
+else
+/* Position's w is 1/w */
+ureg_RCP(ureg, rFog, _(vPos));
+
 if (key->fog_mode == D3DFOG_EXP) {
-ureg_MUL(ureg, rFog, _(vPos), _(_CONST(22)));
+ureg_MUL(ureg, rFog, _X(rFog), _(_CONST(22)));
 ureg_MUL(ureg, rFog, _X(rFog), ureg_imm1f(ureg, -1.442695f));
 ureg_EX2(ureg, rFog, _X(rFog));
 } else
 if (key->fog_mode == D3DFOG_EXP2) {
-ureg_MUL(ureg, rFog, _(vPos), _(_CONST(22)));
+ureg_MUL(ureg, rFog, _X(rFog), _(_CONST(22)));
 ureg_MUL(ureg, rFog, _X(rFog), _X(rFog));
 ureg_MUL(ureg, rFog, _X(rFog), ureg_imm1f(ureg, -1.442695f));
 ureg_EX2(ureg, rFog, _X(rFog));
 } else
 if (key->fog_mode == D3DFOG_LINEAR) {
-ureg_SUB(ureg, rFog, _(_CONST(22)), _(vPos));
+ureg_SUB(ureg, rFog, _(_CONST(22)), _X(rFog));
 ureg_MUL(ureg, ureg_saturate(rFog), _X(rFog), _(_CONST(22)));
 }
 ureg_LRP(ureg, ureg_writemask(oCol, TGSI_WRITEMASK_XYZ), _X(rFog), 
ps.rCurSrc, _CONST(21));
@@ -1690,10 +1707,14 @@ nine_ff_get_vs(struct NineDevice9 *device)
 return vs;
 }
 
+#define GET_D3DTS(n) nine_state_access_transform(state, D3DTS_##n, FALSE)
+#define IS_D3DTS_DIRTY(s,n) ((s)->ff.changed.transform[(D3DTS_##n) / 32] & (1 
<< ((D3DTS_##n) % 32)))
+
 static struct NinePixelShader9 *
 nine_ff_get_ps(struct NineDevice9 *device)
 {
 struct nine_state *state = >state;
+D3DMATRIX *projection_matrix = GET_D3DTS(PROJECTION);
 struct NinePixelShader9 *ps;
 enum pipe_error err;
 struct nine_ff_ps_key key;
@@ -1803,6 +1824,15 @@ nine_ff_get_ps(struct NineDevice9 *device)
 if (state->rs[D3DRS_FOGENABLE])
 key.fog_mode = state->rs[D3DRS_FOGTABLEMODE];
 key.fog = !!state->rs[D3DRS_FOGENABLE];
+/* Pixel fog (with WFOG advertised): source is either Z or W.
+ * W is the source if vs ff is used, and the
+ * projection matrix is not orthogonal.
+ * Tests on Win 10 seem to indicate _34
+ * and _33 are checked against 0, 1. */
+if (key.fog_mode && key.fog)
+key.fog_source = !state->programmable_vs &&
+!(projection_matrix->_34 == 0.0f &&
+  projection_matrix->_44 == 1.0f);
 
 ps = util_hash_table_get(device->ff.ht_ps, );
 if (ps)
@@ -1825,8 +1855,6 @@ nine_ff_get_ps(struct NineDevice9 *device)
 return ps;
 }
 
-#define GET_D3DTS(n) nine_state_access_transform(state, D3DTS_##n, FALSE)
-#define IS_D3DTS_DIRTY(s,n) ((s)->ff.changed.transform[(D3DTS_##n) / 32] & (1 
<< ((D3DTS_##n) % 32)))
 static void
 

[Mesa-dev] [PATCH 25/36] st/nine: Ignore MULTISAMPLEMASK when RT is not multisampled

2016-12-07 Thread Axel Davy
We were ignoring MULTISAMPLEMASK for non-maskable multisample
modes, but we were missing the non-multisampled case.

Fixes a crash in Halo.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/device9.c| 4 ++--
 src/gallium/state_trackers/nine/nine_state.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/nine/device9.c 
b/src/gallium/state_trackers/nine/device9.c
index 62f2e8e..3523748 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -1842,8 +1842,8 @@ NineDevice9_SetRenderTarget( struct NineDevice9 *This,
 This->state.changed.group |= NINE_STATE_VIEWPORT | NINE_STATE_SCISSOR 
| NINE_STATE_MULTISAMPLE;
 
 if (This->state.rt[0] &&
-(This->state.rt[0]->desc.MultiSampleType == 
D3DMULTISAMPLE_NONMASKABLE) !=
-(rt->desc.MultiSampleType == D3DMULTISAMPLE_NONMASKABLE))
+(This->state.rt[0]->desc.MultiSampleType <= 
D3DMULTISAMPLE_NONMASKABLE) !=
+(rt->desc.MultiSampleType <= D3DMULTISAMPLE_NONMASKABLE))
 This->state.changed.group |= NINE_STATE_SAMPLE_MASK;
 }
 
diff --git a/src/gallium/state_trackers/nine/nine_state.c 
b/src/gallium/state_trackers/nine/nine_state.c
index 503ff5c..9e2dfc6 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -1100,7 +1100,7 @@ nine_update_state(struct NineDevice9 *device)
 pipe->set_blend_color(pipe, );
 }
 if (group & NINE_STATE_SAMPLE_MASK) {
-if (state->rt[0]->desc.MultiSampleType == 
D3DMULTISAMPLE_NONMASKABLE) {
+if (state->rt[0]->desc.MultiSampleType <= 
D3DMULTISAMPLE_NONMASKABLE) {
 pipe->set_sample_mask(pipe, ~0);
 } else {
 pipe->set_sample_mask(pipe, state->rs[D3DRS_MULTISAMPLEMASK]);
-- 
2.10.2

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


[Mesa-dev] [PATCH 18/36] st/nine: Silent warnings with guid_str

2016-12-07 Thread Axel Davy
In non-debug build, the variables are unused,
and thus trigger a compilation warning.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/iunknown.c | 8 
 src/gallium/state_trackers/nine/surface9.c | 2 ++
 src/gallium/state_trackers/nine/volume9.c  | 2 ++
 3 files changed, 12 insertions(+)

diff --git a/src/gallium/state_trackers/nine/iunknown.c 
b/src/gallium/state_trackers/nine/iunknown.c
index c0d2b0d..28e4756 100644
--- a/src/gallium/state_trackers/nine/iunknown.c
+++ b/src/gallium/state_trackers/nine/iunknown.c
@@ -78,6 +78,8 @@ NineUnknown_QueryInterface( struct NineUnknown *This,
 DBG("This=%p riid=%p id=%s ppvObject=%p\n",
 This, riid, riid ? GUID_sprintf(guid_str, riid) : "", ppvObject);
 
+(void)guid_str;
+
 if (!ppvObject) return E_POINTER;
 
 do {
@@ -164,6 +166,8 @@ NineUnknown_SetPrivateData( struct NineUnknown *This,
 DBG("This=%p GUID=%s pData=%p SizeOfData=%u Flags=%x\n",
 This, GUID_sprintf(guid_str, refguid), pData, SizeOfData, Flags);
 
+(void)guid_str;
+
 if (Flags & D3DSPD_IUNKNOWN)
 user_assert(SizeOfData == sizeof(IUnknown *), D3DERR_INVALIDCALL);
 
@@ -213,6 +217,8 @@ NineUnknown_GetPrivateData( struct NineUnknown *This,
 DBG("This=%p GUID=%s pData=%p pSizeOfData=%p\n",
 This, GUID_sprintf(guid_str, refguid), pData, pSizeOfData);
 
+(void)guid_str;
+
 header = util_hash_table_get(This->pdata, refguid);
 if (!header) { return D3DERR_NOTFOUND; }
 
@@ -243,6 +249,8 @@ NineUnknown_FreePrivateData( struct NineUnknown *This,
 
 DBG("This=%p GUID=%s\n", This, GUID_sprintf(guid_str, refguid));
 
+(void)guid_str;
+
 header = util_hash_table_get(This->pdata, refguid);
 if (!header)
 return D3DERR_NOTFOUND;
diff --git a/src/gallium/state_trackers/nine/surface9.c 
b/src/gallium/state_trackers/nine/surface9.c
index a172a10..54d07dc 100644
--- a/src/gallium/state_trackers/nine/surface9.c
+++ b/src/gallium/state_trackers/nine/surface9.c
@@ -285,6 +285,8 @@ NineSurface9_GetContainer( struct NineSurface9 *This,
 DBG("This=%p riid=%p id=%s ppContainer=%p\n",
 This, riid, riid ? GUID_sprintf(guid_str, riid) : "", ppContainer);
 
+(void)guid_str;
+
 if (!ppContainer) return E_POINTER;
 
 /* Return device for OffscreenPlainSurface, DepthStencilSurface and 
RenderTarget */
diff --git a/src/gallium/state_trackers/nine/volume9.c 
b/src/gallium/state_trackers/nine/volume9.c
index a31dc0a..33f7cf3 100644
--- a/src/gallium/state_trackers/nine/volume9.c
+++ b/src/gallium/state_trackers/nine/volume9.c
@@ -166,6 +166,8 @@ NineVolume9_GetContainer( struct NineVolume9 *This,
 DBG("This=%p riid=%p id=%s ppContainer=%p\n",
 This, riid, riid ? GUID_sprintf(guid_str, riid) : "", ppContainer);
 
+(void)guid_str;
+
 if (!NineUnknown(This)->container)
 return E_NOINTERFACE;
 return NineUnknown_QueryInterface(NineUnknown(This)->container, riid, 
ppContainer);
-- 
2.10.2

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


[Mesa-dev] [PATCH 23/36] st/nine: Add new driconf options to control DISCARD behaviour

2016-12-07 Thread Axel Davy
See the patch for the new controls added.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/adapter9.h  |  2 ++
 src/gallium/state_trackers/nine/swapchain9.c|  4 ++--
 src/gallium/targets/d3dadapter9/drm.c   | 17 +
 src/mesa/drivers/dri/common/xmlpool/t_options.h | 10 ++
 4 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/nine/adapter9.h 
b/src/gallium/state_trackers/nine/adapter9.h
index aaf7435..4a71540 100644
--- a/src/gallium/state_trackers/nine/adapter9.h
+++ b/src/gallium/state_trackers/nine/adapter9.h
@@ -39,6 +39,8 @@ struct d3dadapter9_context
 int throttling_value;
 int vblank_mode;
 BOOL thread_submit;
+BOOL discard_delayed_release;
+BOOL tearfree_discard;
 
 void (*destroy)( struct d3dadapter9_context *ctx );
 };
diff --git a/src/gallium/state_trackers/nine/swapchain9.c 
b/src/gallium/state_trackers/nine/swapchain9.c
index 79530f5..8a405f2 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -72,8 +72,8 @@ NineSwapChain9_ctor( struct NineSwapChain9 *This,
 D3DPRESENT_PARAMETERS2 params2;
 
 memset(, 0, sizeof(D3DPRESENT_PARAMETERS2));
-params2.AllowDISCARDDelayedRelease = TRUE;
-params2.TearFreeDISCARD = FALSE;
+params2.AllowDISCARDDelayedRelease = 
This->actx->discard_delayed_release;
+params2.TearFreeDISCARD = This->actx->tearfree_discard;
 ID3DPresent_SetPresentParameters2(pPresent, );
 }
 
diff --git a/src/gallium/targets/d3dadapter9/drm.c 
b/src/gallium/targets/d3dadapter9/drm.c
index 767a17a..e0c2e26 100644
--- a/src/gallium/targets/d3dadapter9/drm.c
+++ b/src/gallium/targets/d3dadapter9/drm.c
@@ -56,6 +56,8 @@ DRI_CONF_BEGIN
 DRI_CONF_NINE_OVERRIDEVENDOR(-1)
 DRI_CONF_NINE_THROTTLE(-2)
 DRI_CONF_NINE_THREADSUBMIT("false")
+DRI_CONF_NINE_ALLOWDISCARDDELAYEDRELEASE("true")
+DRI_CONF_NINE_TEARFREEDISCARD("false")
 DRI_CONF_SECTION_END
 DRI_CONF_END;
 
@@ -284,6 +286,21 @@ drm_create_adapter( int fd,
 override_vendorid = driQueryOptioni(, 
"override_vendorid");
 }
 
+if (driCheckOption(, "discard_delayed_release", DRI_BOOL))
+ctx->base.discard_delayed_release = driQueryOptionb(, 
"discard_delayed_release");
+else
+ctx->base.discard_delayed_release = TRUE;
+
+if (driCheckOption(, "tearfree_discard", DRI_BOOL))
+ctx->base.tearfree_discard = driQueryOptionb(, 
"tearfree_discard");
+else
+ctx->base.tearfree_discard = FALSE;
+
+if (ctx->base.tearfree_discard && !ctx->base.discard_delayed_release) {
+ERR("tearfree_discard requires discard_delayed_release\n");
+ctx->base.tearfree_discard = FALSE;
+}
+
 driDestroyOptionCache();
 driDestroyOptionInfo();
 
diff --git a/src/mesa/drivers/dri/common/xmlpool/t_options.h 
b/src/mesa/drivers/dri/common/xmlpool/t_options.h
index 341c376..7b78105 100644
--- a/src/mesa/drivers/dri/common/xmlpool/t_options.h
+++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h
@@ -376,3 +376,13 @@ DRI_CONF_OPT_END
 DRI_CONF_OPT_BEGIN(override_vendorid, int, def) \
 DRI_CONF_DESC(en,"Define the vendor_id to report. This allows faking 
another hardware vendor.") \
 DRI_CONF_OPT_END
+
+#define DRI_CONF_NINE_ALLOWDISCARDDELAYEDRELEASE(def) \
+DRI_CONF_OPT_BEGIN_B(discard_delayed_release, def) \
+DRI_CONF_DESC(en,gettext("Whether to allow the display server to 
release buffers with a delay when using d3d's presentation mode DISCARD. 
Default to true. Set to false if suffering from lag (thread_submit=true can 
also help in this situation).")) \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_NINE_TEARFREEDISCARD(def) \
+DRI_CONF_OPT_BEGIN_B(tearfree_discard, def) \
+DRI_CONF_DESC(en,gettext("Whether to make d3d's presentation mode 
DISCARD (games usually use that mode) Tear Free. If rendering above screen 
refresh, some frames will get skipped. false by default.")) \
+DRI_CONF_OPT_END
-- 
2.10.2

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


[Mesa-dev] [PATCH 11/36] st/nine: Add missing changed states to pixel stateblocks

2016-12-07 Thread Axel Davy
Some states were not properly recorded in pixel stateblocks.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/device9.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/device9.c 
b/src/gallium/state_trackers/nine/device9.c
index 1796fa3..5b4d2ae 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -2520,7 +2520,10 @@ NineDevice9_CreateStateBlock( struct NineDevice9 *This,
 }
 if (Type == D3DSBT_ALL || Type == D3DSBT_PIXELSTATE) {
dst->changed.group |=
-  NINE_STATE_PS | NINE_STATE_PS_CONST;
+  NINE_STATE_PS | NINE_STATE_PS_CONST | NINE_STATE_BLEND |
+  NINE_STATE_FF_OTHER | NINE_STATE_FF_PSSTAGES | NINE_STATE_PS_CONST |
+  NINE_STATE_FB | NINE_STATE_DSA | NINE_STATE_MULTISAMPLE |
+  NINE_STATE_RASTERIZER | NINE_STATE_STENCIL_REF;
/* TODO: texture/sampler state */
memcpy(dst->changed.rs,
   nine_render_states_pixel, sizeof(dst->changed.rs));
-- 
2.10.2

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


[Mesa-dev] [PATCH 00/36] Some gallium nine fixes

2016-12-07 Thread Axel Davy
This serie fixes several gallium nine bugs.
There is also a few cleanups.

It also has a new feature: new options are added
to choose the behaviour of the swapchain DISCARD
mode (which is the most common mode).
Basically the default is that when vsync is off,
the frames are presented as soon as possible, causing
tearing. The new option enables to avoid tearing by waiting
the next vblank, while not blocking rendering (some frames
are thus dropped). Some games has weird physics with vblank
(because of the blocking behaviour), thus why it is often let
off. It makes thus sense to use the new proposed behaviour (which
is equivalent to the 'opengl triple buffering').

Axel Davy (36):
  st/nine: Improve doc of D3DPMISCCAPS_POSTBLENDSRGBCONVERT
  st/nine: Add validation to SetSamplerState
  st/nine: Remove useless call to nine_update_state
  st/nine: Don't update stream_usage_mask in sw path
  st/nine: Fix useless swapchain init checks
  st/nine: Fix ps multisample check
  st/nine: Remove unused ff.changed.group
  st/nine: Fix bad light initialization in stateblocks
  st/nine: Remove useless check in surface9 ctor
  st/nine: Add some debug info in stateblocks
  st/nine: Add missing changed states to pixel stateblocks
  st/nine: Capture texturestage states in pixel stateblocks
  st/nine: Avoid crash on empty Draw*Up
  st/nine: Handle when cursor stride is not what is expected
  st/nine: Correctly release sw cursor image
  st/nine: Fix leak in user constant upload path
  st/nine: Do not generate gallium NOP on d3d NOP
  st/nine: Silent warnings with guid_str
  d3dadapter/present: Add new API to ID3DPresent
  d3dadapter/present: Add precision for WaitBufferReleased
  st/nine: Fix a leak in Swapchain dtor
  st/nine: Rework buffer presentation path
  st/nine: Add new driconf options to control DISCARD behaviour
  driconf: Fix missing gettext
  st/nine: Ignore MULTISAMPLEMASK when RT is not multisampled
  st/nine: Fix specular enable for alpha
  st/nine: Fix ff COLOR0 w component computation
  st/nine: Do not saturate illumination coefficients in ff
  st/nine: Fix check for ff specular
  st/nine: Always initialize current in ff ps
  st/nine: Fix ff cases when stages should be disabled
  st/nine: Remove useless code in ff ps
  st/nine: Fix two special cases in ff ps
  st/nine: Convert redundant check to assert in ff ps
  st/nine: Fix ff texture coordinate selection
  st/nine: Implement WFOG properly

 include/d3dadapter/present.h|  29 +++-
 src/gallium/state_trackers/nine/adapter9.c  |   2 +-
 src/gallium/state_trackers/nine/adapter9.h  |   2 +
 src/gallium/state_trackers/nine/device9.c   |  68 +---
 src/gallium/state_trackers/nine/device9.h   |   1 +
 src/gallium/state_trackers/nine/iunknown.c  |   8 +
 src/gallium/state_trackers/nine/nine_ff.c   | 196 ---
 src/gallium/state_trackers/nine/nine_limits.h   |  36 +
 src/gallium/state_trackers/nine/nine_shader.c   |   9 +-
 src/gallium/state_trackers/nine/nine_state.c|  52 ---
 src/gallium/state_trackers/nine/nine_state.h|   2 +-
 src/gallium/state_trackers/nine/pixelshader9.h  |   2 +-
 src/gallium/state_trackers/nine/stateblock9.c   |  17 +-
 src/gallium/state_trackers/nine/surface9.c  |   6 +-
 src/gallium/state_trackers/nine/swapchain9.c| 197 +---
 src/gallium/state_trackers/nine/swapchain9.h|   1 +
 src/gallium/state_trackers/nine/volume9.c   |   2 +
 src/gallium/targets/d3dadapter9/drm.c   |  17 ++
 src/mesa/drivers/dri/common/xmlpool/t_options.h |  12 +-
 19 files changed, 453 insertions(+), 206 deletions(-)

-- 
2.10.2

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


[Mesa-dev] [PATCH 02/36] st/nine: Add validation to SetSamplerState

2016-12-07 Thread Axel Davy
Check value validity and mimick Win behaviour.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/device9.c |  9 ---
 src/gallium/state_trackers/nine/nine_limits.h | 36 +++
 src/gallium/state_trackers/nine/nine_state.c  |  2 ++
 src/gallium/state_trackers/nine/nine_state.h  |  1 +
 src/gallium/state_trackers/nine/stateblock9.c |  3 +++
 5 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/nine/device9.c 
b/src/gallium/state_trackers/nine/device9.c
index c0a3c39..055e71d 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -2766,7 +2766,7 @@ NineDevice9_GetSamplerState( struct NineDevice9 *This,
 if (Sampler >= D3DDMAPSAMPLER)
 Sampler = Sampler - D3DDMAPSAMPLER + NINE_MAX_SAMPLERS_PS;
 
-*pValue = This->state.samp[Sampler][Type];
+*pValue = This->state.samp_advertised[Sampler][Type];
 return D3D_OK;
 }
 
@@ -2789,8 +2789,11 @@ NineDevice9_SetSamplerState( struct NineDevice9 *This,
 if (Sampler >= D3DDMAPSAMPLER)
 Sampler = Sampler - D3DDMAPSAMPLER + NINE_MAX_SAMPLERS_PS;
 
-if (state->samp[Sampler][Type] != Value || unlikely(This->is_recording)) {
-state->samp[Sampler][Type] = Value;
+if (state->samp_advertised[Sampler][Type] != Value || 
unlikely(This->is_recording)) {
+/* Contrary to render states, old value is kept if new value is wrong 
(except intel + Value == 0) */
+if (likely(nine_check_sampler_state_value(Type, Value)))
+state->samp[Sampler][Type] = Value;
+state->samp_advertised[Sampler][Type] = Value;
 state->changed.group |= NINE_STATE_SAMPLER;
 state->changed.sampler[Sampler] |= 1 << Type;
 }
diff --git a/src/gallium/state_trackers/nine/nine_limits.h 
b/src/gallium/state_trackers/nine/nine_limits.h
index ef1ed25..b5090da 100644
--- a/src/gallium/state_trackers/nine/nine_limits.h
+++ b/src/gallium/state_trackers/nine/nine_limits.h
@@ -208,4 +208,40 @@ nine_fix_render_state_value(D3DRENDERSTATETYPE State,
 return Value;
 }
 
+struct nine_limits
+{
+unsigned min;
+unsigned max;
+};
+
+#define __VALUE_SAMP(o, m, M) \
+[D3DSAMP_##o] = {m, M}
+
+static const struct nine_limits
+sampler_state_limits_table[D3DRS_BLENDOPALPHA + 1] = {
+__VALUE_SAMP(ADDRESSU, 1, 5),
+__VALUE_SAMP(ADDRESSV, 1, 5),
+__VALUE_SAMP(ADDRESSW, 1, 5),
+__VALUE_SAMP(BORDERCOLOR, 0, 0x),
+__VALUE_SAMP(MAGFILTER, 0, 8), /* 4-5 should be forbidden */
+__VALUE_SAMP(MINFILTER, 0, 8), /* same */
+__VALUE_SAMP(MIPFILTER, 0, 8), /* same */
+__VALUE_SAMP(MIPMAPLODBIAS, 0, 0x),
+__VALUE_SAMP(MAXMIPLEVEL, 0, 0x),
+__VALUE_SAMP(MAXANISOTROPY, 1, 0x), /* Max value should be 
pCaps->MaxAnisotropy */
+__VALUE_SAMP(SRGBTEXTURE, 0, 1),
+__VALUE_SAMP(ELEMENTINDEX, 0, 0x),
+__VALUE_SAMP(DMAPOFFSET, 0, 0x)
+};
+
+static BOOL inline
+nine_check_sampler_state_value(D3DSAMPLERSTATETYPE State,
+   DWORD Value)
+{
+struct nine_limits limit;
+
+limit = sampler_state_limits_table[State];
+return (limit.min <= Value && Value <= limit.max);
+}
+
 #endif /* _NINE_HELPERS_H_ */
diff --git a/src/gallium/state_trackers/nine/nine_state.c 
b/src/gallium/state_trackers/nine/nine_state.c
index ea72c77..57f7b2d 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -1306,6 +1306,8 @@ nine_state_set_defaults(struct NineDevice9 *device, const 
D3DCAPS9 *caps,
 for (s = 0; s < ARRAY_SIZE(state->samp); ++s) {
 memcpy(>samp[s], nine_samp_state_defaults,
sizeof(state->samp[s]));
+memcpy(>samp_advertised[s], nine_samp_state_defaults,
+   sizeof(state->samp_advertised[s]));
 }
 
 if (state->vs_const_f)
diff --git a/src/gallium/state_trackers/nine/nine_state.h 
b/src/gallium/state_trackers/nine/nine_state.h
index 1c50775..714f1a9 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -199,6 +199,7 @@ struct nine_state
 struct NineBaseTexture9 *texture[NINE_MAX_SAMPLERS]; /* PS, DMAP, VS */
 
 DWORD samp[NINE_MAX_SAMPLERS][NINED3DSAMP_COUNT];
+DWORD samp_advertised[NINE_MAX_SAMPLERS][NINED3DSAMP_COUNT];
 uint32_t samplers_shadow;
 uint8_t bound_samplers_mask_vs;
 uint16_t bound_samplers_mask_ps;
diff --git a/src/gallium/state_trackers/nine/stateblock9.c 
b/src/gallium/state_trackers/nine/stateblock9.c
index 102213e..75754df 100644
--- a/src/gallium/state_trackers/nine/stateblock9.c
+++ b/src/gallium/state_trackers/nine/stateblock9.c
@@ -245,12 +245,14 @@ nine_state_copy_common(struct NineDevice9 *device,
 for (s = 0; s < NINE_MAX_SAMPLERS; ++s) {
 if (mask->changed.sampler[s] == 0x3ffe) {
 memcpy(>samp[s], >samp[s], sizeof(dst->samp[s]));
+ 

[Mesa-dev] [PATCH 16/36] st/nine: Fix leak in user constant upload path

2016-12-07 Thread Axel Davy
The new code properly releases the previous buffers
allocated.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_ff.c| 22 +++--
 src/gallium/state_trackers/nine/nine_state.c | 46 
 2 files changed, 39 insertions(+), 29 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c 
b/src/gallium/state_trackers/nine/nine_ff.c
index cc09926..f4ec6aa 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -2040,17 +2040,18 @@ nine_ff_update(struct NineDevice9 *device)
 cb.buffer_size = NINE_FF_NUM_VS_CONST * 4 * sizeof(float);
 
 if (!device->driver_caps.user_cbufs) {
+state->pipe.cb_vs_ff.buffer_size = cb.buffer_size;
 u_upload_data(device->constbuf_uploader,
   0,
   cb.buffer_size,
   device->constbuf_alignment,
   cb.user_buffer,
-  _offset,
-  );
+  >pipe.cb_vs_ff.buffer_offset,
+  >pipe.cb_vs_ff.buffer);
 u_upload_unmap(device->constbuf_uploader);
-cb.user_buffer = NULL;
-}
-state->pipe.cb_vs_ff = cb;
+state->pipe.cb_vs_ff.user_buffer = NULL;
+} else
+state->pipe.cb_vs_ff = cb;
 state->commit |= NINE_STATE_COMMIT_CONST_VS;
 }
 
@@ -2063,17 +2064,18 @@ nine_ff_update(struct NineDevice9 *device)
 cb.buffer_size = NINE_FF_NUM_PS_CONST * 4 * sizeof(float);
 
 if (!device->driver_caps.user_cbufs) {
+state->pipe.cb_ps_ff.buffer_size = cb.buffer_size;
 u_upload_data(device->constbuf_uploader,
   0,
   cb.buffer_size,
   device->constbuf_alignment,
   cb.user_buffer,
-  _offset,
-  );
+  >pipe.cb_ps_ff.buffer_offset,
+  >pipe.cb_ps_ff.buffer);
 u_upload_unmap(device->constbuf_uploader);
-cb.user_buffer = NULL;
-}
-state->pipe.cb_ps_ff = cb;
+state->pipe.cb_ps_ff.user_buffer = NULL;
+} else
+state->pipe.cb_ps_ff = cb;
 state->commit |= NINE_STATE_COMMIT_CONST_PS;
 }
 
diff --git a/src/gallium/state_trackers/nine/nine_state.c 
b/src/gallium/state_trackers/nine/nine_state.c
index 69f0cff..503ff5c 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -89,7 +89,6 @@ prepare_vs_constants_userbuf_swvp(struct NineDevice9 *device)
 if (state->changed.vs_const_f || state->changed.group & NINE_STATE_SWVP) {
 struct pipe_constant_buffer cb;
 
-cb.buffer = NULL;
 cb.buffer_offset = 0;
 cb.buffer_size = 4096 * sizeof(float[4]);
 cb.user_buffer = state->vs_const_f_swvp;
@@ -111,32 +110,41 @@ prepare_vs_constants_userbuf_swvp(struct NineDevice9 
*device)
 cb.user_buffer = dst;
 }
 
-state->pipe.cb0_swvp = cb;
+/* Do not erase the buffer field.
+ * It is either NULL (user_cbufs), or a resource.
+ * u_upload_data will do the proper refcount */
+state->pipe.cb0_swvp.buffer_offset = cb.buffer_offset;
+state->pipe.cb0_swvp.buffer_size = cb.buffer_size;
+state->pipe.cb0_swvp.user_buffer = cb.user_buffer;
 
 cb.user_buffer = (char *)cb.user_buffer + 4096 * sizeof(float[4]);
-state->pipe.cb1_swvp = cb;
+state->pipe.cb1_swvp.buffer_offset = cb.buffer_offset;
+state->pipe.cb1_swvp.buffer_size = cb.buffer_size;
+state->pipe.cb1_swvp.user_buffer = cb.user_buffer;
 }
 
 if (state->changed.vs_const_i || state->changed.group & NINE_STATE_SWVP) {
 struct pipe_constant_buffer cb;
 
-cb.buffer = NULL;
 cb.buffer_offset = 0;
 cb.buffer_size = 2048 * sizeof(float[4]);
 cb.user_buffer = state->vs_const_i;
 
-state->pipe.cb2_swvp = cb;
+state->pipe.cb2_swvp.buffer_offset = cb.buffer_offset;
+state->pipe.cb2_swvp.buffer_size = cb.buffer_size;
+state->pipe.cb2_swvp.user_buffer = cb.user_buffer;
 }
 
 if (state->changed.vs_const_b || state->changed.group & NINE_STATE_SWVP) {
 struct pipe_constant_buffer cb;
 
-cb.buffer = NULL;
 cb.buffer_offset = 0;
 cb.buffer_size = 512 * sizeof(float[4]);
 cb.user_buffer = state->vs_const_b;
 
-state->pipe.cb3_swvp = cb;
+state->pipe.cb3_swvp.buffer_offset = cb.buffer_offset;
+state->pipe.cb3_swvp.buffer_size = cb.buffer_size;
+state->pipe.cb3_swvp.user_buffer = cb.user_buffer;
 }
 
 if (!device->driver_caps.user_cbufs) {
@@ -282,18 +290,18 @@ prepare_vs_constants_userbuf(struct 

[Mesa-dev] [PATCH 14/36] st/nine: Handle when cursor stride is not what is expected

2016-12-07 Thread Axel Davy
SetCursor assumes for now a 32x32 argb cursor with pitch 128.
32x32 argb doesn't have pitch 128 on all hw, thus use a
temporary surface with the correct pitch when needed.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/device9.c | 20 ++--
 src/gallium/state_trackers/nine/device9.h |  1 +
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/nine/device9.c 
b/src/gallium/state_trackers/nine/device9.c
index ddac548..a78d18e 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -315,6 +315,11 @@ NineDevice9_ctor( struct NineDevice9 *This,
 This->cursor.image = pScreen->resource_create(pScreen, );
 if (!This->cursor.image)
 return D3DERR_OUTOFVIDEOMEMORY;
+
+/* For uploading 32x32 (argb) cursor */
+This->cursor.hw_upload_temp = MALLOC(32 * 4 * 32);
+if (!This->cursor.hw_upload_temp)
+return D3DERR_OUTOFVIDEOMEMORY;
 }
 
 /* Create constant buffers. */
@@ -506,6 +511,8 @@ NineDevice9_dtor( struct NineDevice9 *This )
 FREE(This->state.vs_const_b);
 FREE(This->state.vs_const_f_swvp);
 
+FREE(This->cursor.hw_upload_temp);
+
 if (This->swapchains) {
 for (i = 0; i < This->nswapchains; ++i)
 if (This->swapchains[i])
@@ -709,11 +716,20 @@ NineDevice9_SetCursorProperties( struct NineDevice9 *This,
  lock.pBits, lock.Pitch,
  This->cursor.w, This->cursor.h);
 
-if (hw_cursor)
+if (hw_cursor) {
+void *data = lock.pBits;
+/* SetCursor assumes 32x32 argb with pitch 128 */
+if (lock.Pitch != 128) {
+sfmt->unpack_rgba_8unorm(This->cursor.hw_upload_temp, 128,
+ lock.pBits, lock.Pitch,
+ 32, 32);
+data = This->cursor.hw_upload_temp;
+}
 hw_cursor = ID3DPresent_SetCursor(This->swapchains[0]->present,
-  lock.pBits,
+  data,
   >cursor.hotspot,
   This->cursor.visible) == D3D_OK;
+}
 
 NineSurface9_UnlockRect(surf);
 }
diff --git a/src/gallium/state_trackers/nine/device9.h 
b/src/gallium/state_trackers/nine/device9.h
index 12be643..d698cee 100644
--- a/src/gallium/state_trackers/nine/device9.h
+++ b/src/gallium/state_trackers/nine/device9.h
@@ -112,6 +112,7 @@ struct NineDevice9
 POINT pos;
 BOOL visible;
 boolean software;
+void *hw_upload_temp;
 } cursor;
 
 struct {
-- 
2.10.2

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


[Mesa-dev] [PATCH 05/36] st/nine: Fix useless swapchain init checks

2016-12-07 Thread Axel Davy
In NineDevice9_SetDefaultState we can assume the
implicit swapchain is properly initialized.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/device9.c | 21 +++--
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/src/gallium/state_trackers/nine/device9.c 
b/src/gallium/state_trackers/nine/device9.c
index 7bdf19f..1796fa3 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -92,25 +92,18 @@ NineDevice9_SetDefaultState( struct NineDevice9 *This, 
boolean is_reset )
 
 nine_state_set_defaults(This, >caps, is_reset);
 
+refSurf = This->swapchains[0]->buffers[0];
+assert(refSurf);
+
 This->state.viewport.X = 0;
 This->state.viewport.Y = 0;
-This->state.viewport.Width = 0;
-This->state.viewport.Height = 0;
+This->state.viewport.Width = refSurf->desc.Width;
+This->state.viewport.Height = refSurf->desc.Height;
 
 This->state.scissor.minx = 0;
 This->state.scissor.miny = 0;
-This->state.scissor.maxx = 0x;
-This->state.scissor.maxy = 0x;
-
-if (This->nswapchains && This->swapchains[0]->params.BackBufferCount)
-refSurf = This->swapchains[0]->buffers[0];
-
-if (refSurf) {
-This->state.viewport.Width = refSurf->desc.Width;
-This->state.viewport.Height = refSurf->desc.Height;
-This->state.scissor.maxx = refSurf->desc.Width;
-This->state.scissor.maxy = refSurf->desc.Height;
-}
+This->state.scissor.maxx = refSurf->desc.Width;
+This->state.scissor.maxy = refSurf->desc.Height;
 
 if (This->nswapchains && 
This->swapchains[0]->params.EnableAutoDepthStencil) {
 This->state.rs[D3DRS_ZENABLE] = TRUE;
-- 
2.10.2

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


[Mesa-dev] [PATCH 31/36] st/nine: Fix ff cases when stages should be disabled

2016-12-07 Thread Axel Davy
When a texture is read by a stage for colorop, it should
be disabled, and disable following stages.

When a texture is read for alphaop, 1.0f is read for the input,
which is the behaviour for a dummy texture.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_ff.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c 
b/src/gallium/state_trackers/nine/nine_ff.c
index b318300..7a09986 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -1709,16 +1709,28 @@ nine_ff_get_ps(struct NineDevice9 *device)
 for (s = 0; s < 8; ++s) {
 key.ts[s].colorop = state->ff.tex_stage[s][D3DTSS_COLOROP];
 key.ts[s].alphaop = state->ff.tex_stage[s][D3DTSS_ALPHAOP];
-/* MSDN says D3DTOP_DISABLE disables this and all subsequent stages. */
-/* ALPHAOP cannot be disabled if COLOROP is enabled. */
+const uint8_t used_c = ps_d3dtop_args_mask(key.ts[s].colorop);
+const uint8_t used_a = ps_d3dtop_args_mask(key.ts[s].alphaop);
+/* MSDN says D3DTOP_DISABLE disables this and all subsequent stages.
+ * ALPHAOP cannot be enabled if COLOROP is disabled.
+ * Verified on Windows. */
 if (key.ts[s].colorop == D3DTOP_DISABLE) {
 key.ts[s].alphaop = D3DTOP_DISABLE; /* DISABLE == 1, avoid 
degenerate keys */
 break;
 }
 
 if (!state->texture[s] &&
-state->ff.tex_stage[s][D3DTSS_COLORARG1] == D3DTA_TEXTURE) {
-/* This should also disable the stage. */
+((state->ff.tex_stage[s][D3DTSS_COLORARG0] == D3DTA_TEXTURE &&
+  used_c & 0x1) ||
+ (state->ff.tex_stage[s][D3DTSS_COLORARG1] == D3DTA_TEXTURE &&
+  used_c & 0x2) ||
+ (state->ff.tex_stage[s][D3DTSS_COLORARG2] == D3DTA_TEXTURE &&
+  used_c & 0x4))) {
+/* Tested on Windows: Invalid texture read disables the stage
+ * and the subsequent ones, but only for colorop. For alpha,
+ * it's as if the texture had alpha of 1.0, which is what
+ * has our dummy texture in that case. Invalid color also
+ * disabled the following alpha stages. */
 key.ts[s].colorop = key.ts[s].alphaop = D3DTOP_DISABLE;
 break;
 }
@@ -1732,7 +1744,6 @@ nine_ff_get_ps(struct NineDevice9 *device)
 sampler_mask |= (1 << s);
 
 if (key.ts[s].colorop != D3DTOP_DISABLE) {
-uint8_t used_c = ps_d3dtop_args_mask(key.ts[s].colorop);
 if (used_c & 0x1) key.ts[s].colorarg0 = 
state->ff.tex_stage[s][D3DTSS_COLORARG0];
 if (used_c & 0x2) key.ts[s].colorarg1 = 
state->ff.tex_stage[s][D3DTSS_COLORARG1];
 if (used_c & 0x4) key.ts[s].colorarg2 = 
state->ff.tex_stage[s][D3DTSS_COLORARG2];
@@ -1744,7 +1755,6 @@ nine_ff_get_ps(struct NineDevice9 *device)
 if (used_c & 0x4) key.colorarg_b5[2] |= 
(state->ff.tex_stage[s][D3DTSS_COLORARG2] >> 5) << s;
 }
 if (key.ts[s].alphaop != D3DTOP_DISABLE) {
-uint8_t used_a = ps_d3dtop_args_mask(key.ts[s].alphaop);
 if (used_a & 0x1) key.ts[s].alphaarg0 = 
state->ff.tex_stage[s][D3DTSS_ALPHAARG0];
 if (used_a & 0x2) key.ts[s].alphaarg1 = 
state->ff.tex_stage[s][D3DTSS_ALPHAARG1];
 if (used_a & 0x4) key.ts[s].alphaarg2 = 
state->ff.tex_stage[s][D3DTSS_ALPHAARG2];
-- 
2.10.2

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


[Mesa-dev] [PATCH 30/36] st/nine: Always initialize current in ff ps

2016-12-07 Thread Axel Davy
The check was not catching all possible cases.
NVE4 should be fine.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_ff.c | 25 +
 1 file changed, 1 insertion(+), 24 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c 
b/src/gallium/state_trackers/nine/nine_ff.c
index ecb1dd8..b318300 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -1332,7 +1332,7 @@ nine_ff_build_ps(struct NineDevice9 *device, struct 
nine_ff_ps_key *key)
 ps.rTexSrc = ureg_src(ps.rTex);
 
 /* Initial values */
-ureg_MOV(ureg, ps.rCur, ureg_imm1f(ureg, 0.0f));
+ureg_MOV(ureg, ps.rCur, ps.vC[0]);
 ureg_MOV(ureg, ps.rTmp, ureg_imm1f(ureg, 0.0f));
 ureg_MOV(ureg, ps.rTex, ureg_imm1f(ureg, 0.0f));
 
@@ -1452,29 +1452,6 @@ nine_ff_build_ps(struct NineDevice9 *device, struct 
nine_ff_ps_key *key)
 ureg_MUL(ureg, ps.rTex, ureg_src(ps.rTex), _X(delta));
 }
 
-if (((s == 0 && key->ts[0].colorop != D3DTOP_BUMPENVMAP &&
-  key->ts[0].colorop != D3DTOP_BUMPENVMAPLUMINANCE) ||
- (s == 1 &&
-  (key->ts[0].colorop == D3DTOP_BUMPENVMAP ||
-   key->ts[0].colorop == D3DTOP_BUMPENVMAPLUMINANCE)))&&
-(key->ts[s].resultarg != 0 /* not current */ ||
- key->ts[s].colorop == D3DTOP_DISABLE ||
- key->ts[s].alphaop == D3DTOP_DISABLE ||
- key->ts[s].colorop == D3DTOP_BLENDCURRENTALPHA ||
- key->ts[s].alphaop == D3DTOP_BLENDCURRENTALPHA ||
- key->ts[s].colorarg0 == D3DTA_CURRENT ||
- key->ts[s].colorarg1 == D3DTA_CURRENT ||
- key->ts[s].colorarg2 == D3DTA_CURRENT ||
- key->ts[s].alphaarg0 == D3DTA_CURRENT ||
- key->ts[s].alphaarg1 == D3DTA_CURRENT ||
- key->ts[s].alphaarg2 == D3DTA_CURRENT)) {
-/* Initialize D3DTA_CURRENT.
- * (Yes we can do this before the loop but not until
- *  NVE4 has an instruction scheduling pass.)
- */
-ureg_MOV(ureg, ps.rCur, ps.vC[0]);
-}
-
 if (key->ts[s].colorop == D3DTOP_BUMPENVMAP ||
 key->ts[s].colorop == D3DTOP_BUMPENVMAPLUMINANCE)
 continue;
-- 
2.10.2

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


[Mesa-dev] [PATCH 19/36] d3dadapter/present: Add new API to ID3DPresent

2016-12-07 Thread Axel Davy
The API will enable better support for the commonly
used DISCARD swapchain parameter.

Signed-off-by: Axel Davy 
---
 include/d3dadapter/present.h | 24 
 1 file changed, 24 insertions(+)

diff --git a/include/d3dadapter/present.h b/include/d3dadapter/present.h
index 187843f..29d7a1a 100644
--- a/include/d3dadapter/present.h
+++ b/include/d3dadapter/present.h
@@ -35,6 +35,22 @@ typedef struct ID3DPresentGroup ID3DPresentGroup;
 typedef struct ID3DAdapter9 ID3DAdapter9;
 typedef struct D3DWindowBuffer D3DWindowBuffer;
 
+/* Available since version 1.3 */
+typedef struct _D3DPRESENT_PARAMETERS2_ {
+/* Whether D3DSWAPEFFECT_DISCARD is allowed to release the
+ * D3DWindowBuffers in any order, and eventually with a delay.
+ * FALSE (Default): buffers should be released as soon as possible.
+ * TRUE: it is allowed to release some buffers with a delay, and in
+ * a random order. */
+BOOL AllowDISCARDDelayedRelease;
+/* User preference for D3DSWAPEFFECT_DISCARD with 
D3DPRESENT_INTERVAL_IMMEDIATE.
+ * FALSE (Default): User prefers presentation to occur as soon as possible,
+ * with potential tearings.
+ * TRUE: User prefers presentation to be tear free. Requires
+ * AllowDISCARDDelayedRelease to have any effect. */
+BOOL TearFreeDISCARD;
+} D3DPRESENT_PARAMETERS2, *PD3DPRESENT_PARAMETERS2, *LPD3DPRESENT_PARAMETERS2;
+
 /* Presentation backend for drivers to display their brilliant work */
 typedef struct ID3DPresentVtbl
 {
@@ -75,6 +91,11 @@ typedef struct ID3DPresentVtbl
 BOOL (WINAPI *ResolutionMismatch)(ID3DPresent *This);
 HANDLE (WINAPI *CreateThread)(ID3DPresent *This, void *pThreadfunc, void 
*pParam);
 BOOL (WINAPI *WaitForThread)(ID3DPresent *This, HANDLE thread);
+/* Available since version 1.3 */
+HRESULT (WINAPI *SetPresentParameters2)(ID3DPresent *This, 
D3DPRESENT_PARAMETERS2 *pParameters);
+BOOL (WINAPI *IsBufferReleased)(ID3DPresent *This, D3DWindowBuffer 
*buffer);
+/* Wait a buffer gets released. */
+HRESULT (WINAPI *WaitBufferReleaseEvent)(ID3DPresent *This);
 } ID3DPresentVtbl;
 
 struct ID3DPresent
@@ -106,6 +127,9 @@ struct ID3DPresent
 #define ID3DPresent_ResolutionMismatch(p) (p)->lpVtbl->ResolutionMismatch(p)
 #define ID3DPresent_CreateThread(p,a,b) (p)->lpVtbl->CreateThread(p,a,b)
 #define ID3DPresent_WaitForThread(p,a) (p)->lpVtbl->WaitForThread(p,a)
+#define ID3DPresent_SetPresentParameters2(p,a) 
(p)->lpVtbl->SetPresentParameters2(p,a)
+#define ID3DPresent_IsBufferReleased(p,a) (p)->lpVtbl->IsBufferReleased(p,a)
+#define ID3DPresent_WaitBufferReleaseEvent(p) 
(p)->lpVtbl->WaitBufferReleaseEvent(p)
 
 typedef struct ID3DPresentGroupVtbl
 {
-- 
2.10.2

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


[Mesa-dev] [PATCH 17/36] st/nine: Do not generate gallium NOP on d3d NOP

2016-12-07 Thread Axel Davy
Some drivers crash if NOP is generated.
Besides there is no point to generate NOP.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_shader.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/nine_shader.c 
b/src/gallium/state_trackers/nine/nine_shader.c
index ab21daf..b959778 100644
--- a/src/gallium/state_trackers/nine/nine_shader.c
+++ b/src/gallium/state_trackers/nine/nine_shader.c
@@ -1573,6 +1573,13 @@ d3dsio_to_string( unsigned opcode )
 static HRESULT
 NineTranslateInstruction_Generic(struct shader_translator *);
 
+DECL_SPECIAL(NOP)
+{
+/* Nothing to do. NOP was used to avoid hangs
+ * with very old d3d drivers. */
+return D3D_OK;
+}
+
 DECL_SPECIAL(M4x4)
 {
 return NineTranslateInstruction_Mkxn(tx, 4, 4);
@@ -2863,7 +2870,7 @@ DECL_SPECIAL(COMMENT)
 
 struct sm1_op_info inst_table[] =
 {
-_OPI(NOP, NOP, V(0,0), V(3,0), V(0,0), V(3,0), 0, 0, NULL), /* 0 */
+_OPI(NOP, NOP, V(0,0), V(3,0), V(0,0), V(3,0), 0, 0, SPECIAL(NOP)), /* 0 */
 _OPI(MOV, MOV, V(0,0), V(3,0), V(0,0), V(3,0), 1, 1, NULL),
 _OPI(ADD, ADD, V(0,0), V(3,0), V(0,0), V(3,0), 1, 2, NULL), /* 2 */
 _OPI(SUB, SUB, V(0,0), V(3,0), V(0,0), V(3,0), 1, 2, NULL), /* 3 */
-- 
2.10.2

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


[Mesa-dev] [PATCH 35/36] st/nine: Fix ff texture coordinate selection

2016-12-07 Thread Axel Davy
The code was wrongly detecting which texture coordinates
to generate when the coordinate index was different to
the stage index.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_ff.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c 
b/src/gallium/state_trackers/nine/nine_ff.c
index f30a988..283a3cd 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -1642,21 +1642,22 @@ nine_ff_get_vs(struct NineDevice9 *device)
 
 for (s = 0; s < 8; ++s) {
 unsigned gen = (state->ff.tex_stage[s][D3DTSS_TEXCOORDINDEX] >> 16) + 
1;
+unsigned idx = state->ff.tex_stage[s][D3DTSS_TEXCOORDINDEX] & 7;
 unsigned dim;
 
 if (key.position_t && gen > NINED3DTSS_TCI_PASSTHRU)
 gen = NINED3DTSS_TCI_PASSTHRU;
 
-if (!input_texture_coord[s] && gen == NINED3DTSS_TCI_PASSTHRU)
+if (!input_texture_coord[idx] && gen == NINED3DTSS_TCI_PASSTHRU)
 gen = NINED3DTSS_TCI_DISABLE;
 
 key.tc_gen |= gen << (s * 3);
-key.tc_idx |= (state->ff.tex_stage[s][D3DTSS_TEXCOORDINDEX] & 7) << (s 
* 3);
-key.tc_dim_input |= ((input_texture_coord[s]-1) & 0x3) << (s * 2);
+key.tc_idx |= idx << (s * 3);
+key.tc_dim_input |= ((input_texture_coord[idx]-1) & 0x3) << (s * 2);
 
 dim = state->ff.tex_stage[s][D3DTSS_TEXTURETRANSFORMFLAGS] & 0x7;
 if (dim > 4)
-dim = input_texture_coord[s];
+dim = input_texture_coord[idx];
 if (dim == 1) /* NV behaviour */
 dim = 0;
 key.tc_dim_output |= dim << (s * 3);
-- 
2.10.2

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


[Mesa-dev] [PATCH 20/36] d3dadapter/present: Add precision for WaitBufferReleased

2016-12-07 Thread Axel Davy
Add precision on the behaviour of WaitBufferReleased.
All implementers and users of the API were expecting
that behaviour.

Signed-off-by: Axel Davy 
---
 include/d3dadapter/present.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/d3dadapter/present.h b/include/d3dadapter/present.h
index 29d7a1a..95e8d67 100644
--- a/include/d3dadapter/present.h
+++ b/include/d3dadapter/present.h
@@ -70,7 +70,10 @@ typedef struct ID3DPresentVtbl
 HRESULT (WINAPI *DestroyD3DWindowBuffer)(ID3DPresent *This, 
D3DWindowBuffer *buffer);
 /* After presenting a buffer to the window system, the buffer
  * may be used as is (no copy of the content) by the window system.
- * You must not use a non-released buffer, else the user may see undefined 
content. */
+ * You must not use a non-released buffer, else the user may see undefined 
content.
+ * Note: This function waits as well that the buffer content was displayed 
(this
+ * can be after the release of the buffer if the window system decided to 
make
+ * an internal copy and release early. */
 HRESULT (WINAPI *WaitBufferReleased)(ID3DPresent *This, D3DWindowBuffer 
*buffer);
 HRESULT (WINAPI *FrontBufferCopy)(ID3DPresent *This, D3DWindowBuffer 
*buffer);
 /* It is possible to do partial copy, but impossible to do resizing, which 
must
-- 
2.10.2

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


[Mesa-dev] [PATCH 28/36] st/nine: Do not saturate illumination coefficients in ff

2016-12-07 Thread Axel Davy
Fixes bad rendering of a test app.
Wine has the same behaviour.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_ff.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c 
b/src/gallium/state_trackers/nine/nine_ff.c
index 8b6f442..a1eb378 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -814,10 +814,6 @@ nine_ff_build_vs(struct NineDevice9 *device, struct 
vs_build_ctx *vs)
 ureg_MOV(ureg, rD, ureg_imm1f(ureg, 0.0f));
 ureg_MOV(ureg, rA, ureg_imm1f(ureg, 0.0f));
 ureg_MOV(ureg, rS, ureg_imm1f(ureg, 0.0f));
-rD = ureg_saturate(rD);
-rA = ureg_saturate(rA);
-rS = ureg_saturate(rS);
-
 
 /* loop management */
 ureg_BGNLOOP(ureg, [loop_label]);
-- 
2.10.2

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


[Mesa-dev] [PATCH 01/36] st/nine: Improve doc of D3DPMISCCAPS_POSTBLENDSRGBCONVERT

2016-12-07 Thread Axel Davy
The cap should be advertised for d3d10 able cards,
but only for Ex contexts.

Unfortunately at this point Mesa has no way to know if
Ex is used or not (the info is got later).

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/adapter9.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/adapter9.c 
b/src/gallium/state_trackers/nine/adapter9.c
index f00590d..98b3255 100644
--- a/src/gallium/state_trackers/nine/adapter9.c
+++ b/src/gallium/state_trackers/nine/adapter9.c
@@ -600,7 +600,7 @@ NineAdapter9_GetDeviceCaps( struct NineAdapter9 *This,
D3DPMISCCAPS_BLENDOP |
D3DPIPECAP(INDEP_BLEND_ENABLE, 
D3DPMISCCAPS_INDEPENDENTWRITEMASKS) |
D3DPMISCCAPS_PERSTAGECONSTANT |
-   /*D3DPMISCCAPS_POSTBLENDSRGBCONVERT |*/ /* TODO 
*/
+   /*D3DPMISCCAPS_POSTBLENDSRGBCONVERT |*/ /* 
TODO: advertise if Ex and dx10 able card */
D3DPMISCCAPS_FOGANDSPECULARALPHA | /* Note: 
documentation of the flag is wrong */
D3DPIPECAP(BLEND_EQUATION_SEPARATE, 
D3DPMISCCAPS_SEPARATEALPHABLEND) |
D3DPIPECAP(MIXED_COLORBUFFER_FORMATS, 
D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS) |
-- 
2.10.2

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


[Mesa-dev] [PATCH 04/36] st/nine: Don't update stream_usage_mask in sw path

2016-12-07 Thread Axel Davy
The variable is used only in the hw path.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_state.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_state.c 
b/src/gallium/state_trackers/nine/nine_state.c
index 57f7b2d..69f0cff 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -1413,7 +1413,6 @@ update_vertex_elements_sw(struct NineDevice9 *device)
 BOOL need_dummy_vbo = FALSE;
 struct pipe_vertex_element ve[PIPE_MAX_ATTRIBS];
 
-state->stream_usage_mask = 0;
 memset(vdecl_index_map, -1, 16);
 memset(used_streams, 0, device->caps.MaxStreams);
 vs = state->programmable_vs ? device->state.vs : device->ff.vs;
@@ -1456,7 +1455,6 @@ update_vertex_elements_sw(struct NineDevice9 *device)
 if (index >= 0) {
 ve[n] = vdecl->elems[index];
 b = ve[n].vertex_buffer_index;
-state->stream_usage_mask |= 1 << b;
 /* XXX wine just uses 1 here: */
 if (state->stream_freq[b] & D3DSTREAMSOURCE_INSTANCEDATA)
 ve[n].instance_divisor = state->stream_freq[b] & 0x7F;
-- 
2.10.2

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


[Mesa-dev] [PATCH 33/36] st/nine: Fix two special cases in ff ps

2016-12-07 Thread Axel Davy
if first alpha stage is disabled and writes to temp,
diffuse alpha is written to temp.
Last stage always writes to current.

Behaviour was deduced by tests with a test app.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_ff.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c 
b/src/gallium/state_trackers/nine/nine_ff.c
index c3245a3..294fbc8 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -1773,6 +1773,26 @@ nine_ff_get_ps(struct NineDevice9 *device)
 }
 }
 
+/* Note: If colorop is D3DTOP_DISABLE for the first stage
+ * (which implies alphaop is too), nothing particular happens,
+ * that is, current is equal to diffuse (which is the case anyway,
+ * because it is how it is initialized).
+ * Special case seems if alphaop is D3DTOP_DISABLE and not colorop,
+ * because then if the resultarg is TEMP, then diffuse alpha is written
+ * to it. */
+if (key.ts[0].colorop != D3DTOP_DISABLE &&
+key.ts[0].alphaop == D3DTOP_DISABLE &&
+key.ts[0].resultarg != 0) {
+key.ts[0].alphaop = D3DTOP_SELECTARG1;
+key.ts[0].alphaarg1 = D3DTA_DIFFUSE;
+}
+/* When no alpha stage writes to current, diffuse alpha is taken.
+ * Since we initialize current to diffuse, we have the behaviour. */
+
+/* Last stage always writes to Current */
+if (s >= 1)
+key.ts[s-1].resultarg = 0;
+
 key.projected = nine_ff_get_projected_key(state);
 key.specular = !!state->rs[D3DRS_SPECULARENABLE];
 
-- 
2.10.2

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


[Mesa-dev] [PATCH 08/36] st/nine: Fix bad light initialization in stateblocks

2016-12-07 Thread Axel Davy
src was initialized instead of dst.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/stateblock9.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/nine/stateblock9.c 
b/src/gallium/state_trackers/nine/stateblock9.c
index 16e60ef..a2b281e 100644
--- a/src/gallium/state_trackers/nine/stateblock9.c
+++ b/src/gallium/state_trackers/nine/stateblock9.c
@@ -326,8 +326,8 @@ nine_state_copy_common(struct NineDevice9 *device,
  * "dst->ff.light[i] = src->ff.light[i];" later,
  * which is what we want in that case. */
 if (mask != dst) {
-for (i = src->ff.num_lights; i < num_lights; ++i)
-src->ff.light[i].Type = (D3DLIGHTTYPE)NINED3DLIGHT_INVALID;
+for (i = dst->ff.num_lights; i < num_lights; ++i)
+dst->ff.light[i].Type = (D3DLIGHTTYPE)NINED3DLIGHT_INVALID;
 }
 dst->ff.num_lights = num_lights;
 }
-- 
2.10.2

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


[Mesa-dev] [PATCH 13/36] st/nine: Avoid crash on empty Draw*Up

2016-12-07 Thread Axel Davy
Ignore empty draw calls.
Avoid assertion fault when such draw calls happen
in u_upload_mgr.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/device9.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/state_trackers/nine/device9.c 
b/src/gallium/state_trackers/nine/device9.c
index 8b03e9b..ddac548 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -3023,6 +3023,7 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This,
 
 user_assert(pVertexStreamZeroData && VertexStreamZeroStride,
 D3DERR_INVALIDCALL);
+user_assert(PrimitiveCount, D3D_OK);
 
 nine_update_state(This);
 
@@ -3089,6 +3090,7 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 
*This,
 user_assert(VertexStreamZeroStride, D3DERR_INVALIDCALL);
 user_assert(IndexDataFormat == D3DFMT_INDEX16 ||
 IndexDataFormat == D3DFMT_INDEX32, D3DERR_INVALIDCALL);
+user_assert(PrimitiveCount, D3D_OK);
 
 nine_update_state(This);
 
-- 
2.10.2

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


[Mesa-dev] [PATCH 09/36] st/nine: Remove useless check in surface9 ctor

2016-12-07 Thread Axel Davy
Textures already have the check in BaseTexture9.
Non-Textures cannot be in the MANAGED Pool.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/surface9.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/src/gallium/state_trackers/nine/surface9.c 
b/src/gallium/state_trackers/nine/surface9.c
index 2efdfd1..a172a10 100644
--- a/src/gallium/state_trackers/nine/surface9.c
+++ b/src/gallium/state_trackers/nine/surface9.c
@@ -68,10 +68,6 @@ NineSurface9_ctor( struct NineSurface9 *This,
 /* Make sure there's a Desc */
 assert(pDesc);
 
-/* D3DUSAGE_DYNAMIC isn't allowed on managed buffers */
-user_assert(!(pDesc->Usage & D3DUSAGE_DYNAMIC) ||
-(pDesc->Pool != D3DPOOL_MANAGED), D3DERR_INVALIDCALL);
-
 assert(allocate || pResource || user_buffer ||
pDesc->Format == D3DFMT_NULL);
 assert(!allocate || (!pResource && !user_buffer));
-- 
2.10.2

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


[Mesa-dev] [PATCH 24/36] driconf: Fix missing gettext

2016-12-07 Thread Axel Davy
DRI_CONF_NINE_OVERRIDEVENDOR was missing gettext for the
description.

Signed-off-by: Axel Davy 
---
 src/mesa/drivers/dri/common/xmlpool/t_options.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/common/xmlpool/t_options.h 
b/src/mesa/drivers/dri/common/xmlpool/t_options.h
index 7b78105..0ab2efc 100644
--- a/src/mesa/drivers/dri/common/xmlpool/t_options.h
+++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h
@@ -374,7 +374,7 @@ DRI_CONF_OPT_END
 
 #define DRI_CONF_NINE_OVERRIDEVENDOR(def) \
 DRI_CONF_OPT_BEGIN(override_vendorid, int, def) \
-DRI_CONF_DESC(en,"Define the vendor_id to report. This allows faking 
another hardware vendor.") \
+DRI_CONF_DESC(en,gettext("Define the vendor_id to report. This allows 
faking another hardware vendor.")) \
 DRI_CONF_OPT_END
 
 #define DRI_CONF_NINE_ALLOWDISCARDDELAYEDRELEASE(def) \
-- 
2.10.2

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


[Mesa-dev] [PATCH 06/36] st/nine: Fix ps multisample check

2016-12-07 Thread Axel Davy
We want to use centroid for nonmaskable
multisampling as well.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/pixelshader9.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/pixelshader9.h 
b/src/gallium/state_trackers/nine/pixelshader9.h
index 9a615b7..9ff3d51 100644
--- a/src/gallium/state_trackers/nine/pixelshader9.h
+++ b/src/gallium/state_trackers/nine/pixelshader9.h
@@ -94,7 +94,7 @@ NinePixelShader9_UpdateKey( struct NinePixelShader9 *ps,
 }
 
 /* centroid interpolation automatically used for color ps inputs */
-if (state->rt[0]->desc.MultiSampleType > 1)
+if (state->rt[0]->base.info.nr_samples)
 key |= ((uint64_t)1) << 34;
 
 if (unlikely(ps->byte_code.version < 0x14)) {
-- 
2.10.2

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


[Mesa-dev] [PATCH 15/36] st/nine: Correctly release sw cursor image

2016-12-07 Thread Axel Davy
cursor.image is used for software cursor
emulation. It wasn't released.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/device9.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/state_trackers/nine/device9.c 
b/src/gallium/state_trackers/nine/device9.c
index a78d18e..62f2e8e 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -511,6 +511,7 @@ NineDevice9_dtor( struct NineDevice9 *This )
 FREE(This->state.vs_const_b);
 FREE(This->state.vs_const_f_swvp);
 
+pipe_resource_reference(>cursor.image, NULL);
 FREE(This->cursor.hw_upload_temp);
 
 if (This->swapchains) {
-- 
2.10.2

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


[Mesa-dev] [PATCH 03/36] st/nine: Remove useless call to nine_update_state

2016-12-07 Thread Axel Davy
The call was not needed.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/device9.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/device9.c 
b/src/gallium/state_trackers/nine/device9.c
index 055e71d..7bdf19f 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -467,7 +467,6 @@ NineDevice9_ctor( struct NineDevice9 *This,
 }
 
 This->update = >state;
-nine_update_state(This);
 
 nine_state_init_sw(This);
 
-- 
2.10.2

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


[Mesa-dev] [PATCH 71/84] st/nine: Implement nine_context_gen_mipmap

2016-12-07 Thread Axel Davy
To offload mipmap generation as well.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_state.c | 15 +++
 src/gallium/state_trackers/nine/nine_state.h |  7 +++
 2 files changed, 22 insertions(+)

diff --git a/src/gallium/state_trackers/nine/nine_state.c 
b/src/gallium/state_trackers/nine/nine_state.c
index 53ff1d5..1f9365b 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -44,6 +44,7 @@
 #include "util/u_math.h"
 #include "util/u_box.h"
 #include "util/u_simple_shaders.h"
+#include "util/u_gen_mipmap.h"
 
 /* CSMT headers */
 #include "nine_queue.h"
@@ -2696,6 +2697,20 @@ CSMT_ITEM_NO_WAIT(nine_context_clear_render_target,
 context->pipe->clear_render_target(context->pipe, surf, , x, y, 
width, height, false);
 }
 
+CSMT_ITEM_NO_WAIT(nine_context_gen_mipmap,
+  ARG_BIND_RES(struct pipe_resource, res),
+  ARG_VAL(UINT, base_level),
+  ARG_VAL(UINT, last_level),
+  ARG_VAL(UINT, first_layer),
+  ARG_VAL(UINT, last_layer),
+  ARG_VAL(UINT, filter))
+{
+struct nine_context *context = >context;
+
+util_gen_mipmap(context->pipe, res, res->format, base_level,
+last_level, first_layer, last_layer, filter);
+}
+
 CSMT_ITEM_NO_WAIT_WITH_COUNTER(nine_context_range_upload,
ARG_BIND_RES(struct pipe_resource, res),
ARG_VAL(unsigned, offset),
diff --git a/src/gallium/state_trackers/nine/nine_state.h 
b/src/gallium/state_trackers/nine/nine_state.h
index c0afbe0..0fa19a2 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -540,6 +540,13 @@ nine_context_clear_render_target(struct NineDevice9 
*device,
  UINT height);
 
 void
+nine_context_gen_mipmap(struct NineDevice9 *device,
+struct pipe_resource *res,
+UINT base_level, UINT last_level,
+UINT first_layer, UINT last_layer,
+UINT filter);
+
+void
 nine_context_range_upload(struct NineDevice9 *device,
   unsigned *counter,
   struct pipe_resource *res,
-- 
2.10.2

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


[Mesa-dev] [PATCH 76/84] st/nine: Fix leak with volume dtor

2016-12-07 Thread Axel Davy
The last level was not released.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/volumetexture9.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/volumetexture9.c 
b/src/gallium/state_trackers/nine/volumetexture9.c
index 4908ed7..5c83fdb 100644
--- a/src/gallium/state_trackers/nine/volumetexture9.c
+++ b/src/gallium/state_trackers/nine/volumetexture9.c
@@ -139,7 +139,7 @@ NineVolumeTexture9_dtor( struct NineVolumeTexture9 *This )
 DBG("This=%p\n", This);
 
 if (This->volumes) {
-for (l = 0; l < This->base.base.info.last_level; ++l)
+for (l = 0; l <= This->base.base.info.last_level; ++l)
 NineUnknown_Destroy(>volumes[l]->base);
 FREE(This->volumes);
 }
-- 
2.10.2

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


[Mesa-dev] [PATCH 70/84] st/nine: Optimize managed buffer upload

2016-12-07 Thread Axel Davy
Do the upload in the other thread.

Usually managed buffers are used once per frame.
It is then very likely pending_upload is 0 at Lock
time.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/buffer9.c |  3 +++
 src/gallium/state_trackers/nine/buffer9.h | 12 +++-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/nine/buffer9.c 
b/src/gallium/state_trackers/nine/buffer9.c
index ca6a1b3..9a7c30c 100644
--- a/src/gallium/state_trackers/nine/buffer9.c
+++ b/src/gallium/state_trackers/nine/buffer9.c
@@ -223,11 +223,14 @@ NineBuffer9_Lock( struct NineBuffer9 *This,
 
 if (This->base.pool == D3DPOOL_MANAGED) {
 /* READONLY doesn't dirty the buffer */
+/* Tests on Win: READONLY doesn't wait for the upload */
 if (!(Flags & D3DLOCK_READONLY)) {
 if (!This->managed.dirty) {
 assert(LIST_IS_EMPTY(>managed.list));
 This->managed.dirty = TRUE;
 This->managed.dirty_box = box;
+if (p_atomic_read(>managed.pending_upload))
+nine_csmt_process(This->base.base.device);
 } else
 u_box_union_2d(>managed.dirty_box, 
>managed.dirty_box, );
 }
diff --git a/src/gallium/state_trackers/nine/buffer9.h 
b/src/gallium/state_trackers/nine/buffer9.h
index d8024e4..e9ee31e 100644
--- a/src/gallium/state_trackers/nine/buffer9.h
+++ b/src/gallium/state_trackers/nine/buffer9.h
@@ -25,6 +25,7 @@
 #define _NINE_BUFFER9_H_
 
 #include "device9.h"
+#include "nine_state.h"
 #include "resource9.h"
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
@@ -57,6 +58,7 @@ struct NineBuffer9
 struct pipe_box dirty_box;
 struct list_head list; /* for update_buffers */
 struct list_head list2; /* for managed_buffers */
+unsigned pending_upload; /* for uploads */
 } managed;
 };
 static inline struct NineBuffer9 *
@@ -92,13 +94,13 @@ NineBuffer9_Unlock( struct NineBuffer9 *This );
 static inline void
 NineBuffer9_Upload( struct NineBuffer9 *This )
 {
-struct pipe_context *pipe = NineDevice9_GetPipe(This->base.base.device);
+struct NineDevice9 *device = This->base.base.device;
 
 assert(This->base.pool == D3DPOOL_MANAGED && This->managed.dirty);
-pipe->buffer_subdata(pipe, This->base.resource, 0,
- This->managed.dirty_box.x,
- This->managed.dirty_box.width,
- (char *)This->managed.data + 
This->managed.dirty_box.x);
+nine_context_range_upload(device, >managed.pending_upload, 
This->base.resource,
+  This->managed.dirty_box.x,
+  This->managed.dirty_box.width,
+  (char *)This->managed.data + 
This->managed.dirty_box.x);
 This->managed.dirty = FALSE;
 }
 
-- 
2.10.2

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


[Mesa-dev] [PATCH 84/84] st/nine: Implement new buffer upload path

2016-12-07 Thread Axel Davy
This new buffer upload path enables to lock
faster than the normal path when using
DISCARD/NOOVERWRITE.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/Makefile.sources   |   2 +
 src/gallium/state_trackers/nine/buffer9.c  |  75 +-
 src/gallium/state_trackers/nine/buffer9.h  |   9 +-
 src/gallium/state_trackers/nine/device9.c  |   5 +
 src/gallium/state_trackers/nine/device9.h  |   3 +
 src/gallium/state_trackers/nine/indexbuffer9.c |  10 +-
 src/gallium/state_trackers/nine/indexbuffer9.h |   2 -
 .../state_trackers/nine/nine_buffer_upload.c   | 288 +
 .../state_trackers/nine/nine_buffer_upload.h   |  59 +
 src/gallium/state_trackers/nine/vertexbuffer9.c|   3 +-
 10 files changed, 435 insertions(+), 21 deletions(-)
 create mode 100644 src/gallium/state_trackers/nine/nine_buffer_upload.c
 create mode 100644 src/gallium/state_trackers/nine/nine_buffer_upload.h

diff --git a/src/gallium/state_trackers/nine/Makefile.sources 
b/src/gallium/state_trackers/nine/Makefile.sources
index 2bb08a2..56698a1 100644
--- a/src/gallium/state_trackers/nine/Makefile.sources
+++ b/src/gallium/state_trackers/nine/Makefile.sources
@@ -23,6 +23,8 @@ C_SOURCES := \
indexbuffer9.h \
iunknown.c \
iunknown.h \
+   nine_buffer_upload.c \
+   nine_buffer_upload.h \
nine_csmt_helper.h \
nine_debug.c \
nine_debug.h \
diff --git a/src/gallium/state_trackers/nine/buffer9.c 
b/src/gallium/state_trackers/nine/buffer9.c
index 9a7c30c..aa97cf9 100644
--- a/src/gallium/state_trackers/nine/buffer9.c
+++ b/src/gallium/state_trackers/nine/buffer9.c
@@ -23,6 +23,7 @@
 
 #include "buffer9.h"
 #include "device9.h"
+#include "nine_buffer_upload.h"
 #include "nine_helpers.h"
 #include "nine_pipe.h"
 
@@ -100,6 +101,9 @@ NineBuffer9_ctor( struct NineBuffer9 *This,
 else
 info->usage = PIPE_USAGE_DYNAMIC;
 
+/* When Writeonly is not set, we don't want to enable the
+ * optimizations */
+This->discard_nooverwrite_only = !!(Usage & D3DUSAGE_WRITEONLY);
 /* if (pDesc->Usage & D3DUSAGE_DONOTCLIP) { } */
 /* if (pDesc->Usage & D3DUSAGE_NONSECURE) { } */
 /* if (pDesc->Usage & D3DUSAGE_NPATCHES) { } */
@@ -161,12 +165,18 @@ NineBuffer9_dtor( struct NineBuffer9 *This )
 list_del(>managed.list2);
 }
 
+if (This->buf)
+nine_upload_release_buffer(This->base.base.device->buffer_upload, 
This->buf);
+
 NineResource9_dtor(>base);
 }
 
 struct pipe_resource *
-NineBuffer9_GetResource( struct NineBuffer9 *This )
+NineBuffer9_GetResource( struct NineBuffer9 *This, unsigned *offset )
 {
+if (This->buf)
+return nine_upload_buffer_resource_and_offset(This->buf, offset);
+*offset = 0;
 return NineResource9_GetResource(>base);
 }
 
@@ -260,6 +270,8 @@ NineBuffer9_Lock( struct NineBuffer9 *This,
 if (Flags & D3DLOCK_DONOTWAIT && !(This->base.usage & D3DUSAGE_DYNAMIC))
 usage |= PIPE_TRANSFER_DONTBLOCK;
 
+This->discard_nooverwrite_only &= !!(Flags & (D3DLOCK_DISCARD | 
D3DLOCK_NOOVERWRITE));
+
 if (This->nmaps == This->maxmaps) {
 struct NineTransfer *newmaps =
 REALLOC(This->maps, sizeof(struct NineTransfer)*This->maxmaps,
@@ -271,8 +283,52 @@ NineBuffer9_Lock( struct NineBuffer9 *This,
 This->maps = newmaps;
 }
 
-This->maps[This->nmaps].is_pipe_secondary = FALSE;
+if (This->buf &&
+(!This->discard_nooverwrite_only ||
+ (This->discard_nooverwrite_only && (Flags & D3DLOCK_DISCARD {
+/* Release previous buffer */
+if (This->nmaps >= 1)
+This->maps[This->nmaps-1].should_destroy_buf = true;
+else
+nine_upload_release_buffer(device->buffer_upload, This->buf);
+This->buf = NULL;
+/* Mapping a nine_subbuffer without discard/nooverwrite.
+ * Since that will hurt (we'll wait the entire buffer
+ * to be idle), we'll won't nine_subbuffer for this buffer
+ * in fear that happens again. */
+if (This->buf && !This->discard_nooverwrite_only) {
+DBG("Disabling nine_subbuffer for a buffer having"
+"used a nine_subbuffer buffer\n");
+/* Rebind previous resource */
+NineBuffer9_RebindIfRequired(This, device);
+}
+}
+
+This->maps[This->nmaps].transfer = NULL;
+This->maps[This->nmaps].is_pipe_secondary = false;
+This->maps[This->nmaps].buf = NULL;
+This->maps[This->nmaps].should_destroy_buf = false;
+
+if (This->discard_nooverwrite_only) {
+if (!This->buf) {
+This->buf = nine_upload_create_buffer(device->buffer_upload, 
This->base.info.width0);
+NineBuffer9_RebindIfRequired(This, device);
+}
+
+if (This->buf) {
+This->maps[This->nmaps].buf = This->buf;
+This->nmaps++;
+*ppbData = 

[Mesa-dev] [PATCH 56/84] st/nine: Add secondary pipe for device

2016-12-07 Thread Axel Davy
The secondary pipe will be used for operations
that don't need synchronization.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/device9.c | 4 +++-
 src/gallium/state_trackers/nine/device9.h | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/device9.c 
b/src/gallium/state_trackers/nine/device9.c
index 8b4bd06..f659a27 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -193,7 +193,8 @@ NineDevice9_ctor( struct NineDevice9 *This,
 This->caps.MaxVertexShaderConst = NINE_MAX_CONST_F_SWVP;
 
 This->context.pipe = This->screen->context_create(This->screen, NULL, 0);
-if (!This->context.pipe) { return E_OUTOFMEMORY; } /* guess */
+This->pipe_secondary = This->screen->context_create(This->screen, NULL, 0);
+if (!This->context.pipe || !This->pipe_secondary) { return E_OUTOFMEMORY; 
} /* guess */
 This->pipe_sw = This->screen_sw->context_create(This->screen_sw, NULL, 0);
 if (!This->pipe_sw) { return E_OUTOFMEMORY; }
 
@@ -574,6 +575,7 @@ NineDevice9_dtor( struct NineDevice9 *This )
 if (This->context.cso) { cso_destroy_context(This->context.cso); }
 if (This->cso_sw) { cso_destroy_context(This->cso_sw); }
 if (This->context.pipe && This->context.pipe->destroy) { 
This->context.pipe->destroy(This->context.pipe); }
+if (This->pipe_secondary && This->pipe_secondary->destroy) { 
This->pipe_secondary->destroy(This->pipe_secondary); }
 if (This->pipe_sw && This->pipe_sw->destroy) { 
This->pipe_sw->destroy(This->pipe_sw); }
 
 if (This->present) { ID3DPresentGroup_Release(This->present); }
diff --git a/src/gallium/state_trackers/nine/device9.h 
b/src/gallium/state_trackers/nine/device9.h
index 4539cda..81c4ef9 100644
--- a/src/gallium/state_trackers/nine/device9.h
+++ b/src/gallium/state_trackers/nine/device9.h
@@ -53,6 +53,8 @@ struct NineDevice9
 
 /* G3D context */
 struct pipe_screen *screen;
+/* For first time upload. No Sync with rendering thread */
+struct pipe_context *pipe_secondary;
 struct pipe_screen *screen_sw;
 struct pipe_context *pipe_sw;
 struct cso_context *cso_sw;
-- 
2.10.2

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


[Mesa-dev] [PATCH 58/84] st/nine: use get_pipe_acquire/release when possible

2016-12-07 Thread Axel Davy
Use the acquire/release semantic when we don't need
to wait for any pending command.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/basetexture9.c  |  8 ++--
 src/gallium/state_trackers/nine/buffer9.c   |  4 +++-
 src/gallium/state_trackers/nine/nine_state.c| 16 ++--
 src/gallium/state_trackers/nine/pixelshader9.c  |  3 ++-
 src/gallium/state_trackers/nine/surface9.c  | 10 +++---
 src/gallium/state_trackers/nine/swapchain9.c|  3 ++-
 src/gallium/state_trackers/nine/vertexshader9.c |  3 ++-
 src/gallium/state_trackers/nine/volume9.c   |  3 ++-
 8 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/src/gallium/state_trackers/nine/basetexture9.c 
b/src/gallium/state_trackers/nine/basetexture9.c
index f37dbb1..ce08c25 100644
--- a/src/gallium/state_trackers/nine/basetexture9.c
+++ b/src/gallium/state_trackers/nine/basetexture9.c
@@ -455,7 +455,6 @@ NineBaseTexture9_CreatePipeResource( struct 
NineBaseTexture9 *This,
 if (!res)
 return D3DERR_OUTOFVIDEOMEMORY;
 This->base.resource = res;
-pipe = NineDevice9_GetPipe(This->base.base.device);
 
 if (old && CopyData) { /* Don't return without releasing old ! */
 struct pipe_box box;
@@ -470,6 +469,8 @@ NineBaseTexture9_CreatePipeResource( struct 
NineBaseTexture9 *This,
 box.height = u_minify(templ.height0, l);
 box.depth = u_minify(templ.depth0, l);
 
+pipe = nine_context_get_pipe_acquire(This->base.base.device);
+
 for (; l <= templ.last_level; ++l, ++m) {
 pipe->resource_copy_region(pipe,
res, l, 0, 0, 0,
@@ -478,6 +479,8 @@ NineBaseTexture9_CreatePipeResource( struct 
NineBaseTexture9 *This,
 box.height = u_minify(box.height, 1);
 box.depth = u_minify(box.depth, 1);
 }
+
+nine_context_get_pipe_release(This->base.base.device);
 }
 pipe_resource_reference(, NULL);
 
@@ -574,8 +577,9 @@ NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 
*This,
 templ.swizzle_a = swizzle[3];
 templ.target = resource->target;
 
-pipe = NineDevice9_GetPipe(This->base.base.device);
+pipe = nine_context_get_pipe_acquire(This->base.base.device);
 This->view[sRGB] = pipe->create_sampler_view(pipe, resource, );
+nine_context_get_pipe_release(This->base.base.device);
 
 DBG("sampler view = %p(resource = %p)\n", This->view[sRGB], resource);
 
diff --git a/src/gallium/state_trackers/nine/buffer9.c 
b/src/gallium/state_trackers/nine/buffer9.c
index 7a2145d..ca6a1b3 100644
--- a/src/gallium/state_trackers/nine/buffer9.c
+++ b/src/gallium/state_trackers/nine/buffer9.c
@@ -323,8 +323,10 @@ NineBuffer9_Unlock( struct NineBuffer9 *This )
 if (This->base.pool != D3DPOOL_MANAGED) {
 pipe = This->maps[This->nmaps].is_pipe_secondary ?
 device->pipe_secondary :
-NineDevice9_GetPipe(device);
+nine_context_get_pipe_acquire(device);
 pipe->transfer_unmap(pipe, This->maps[This->nmaps].transfer);
+if (!This->maps[This->nmaps].is_pipe_secondary)
+nine_context_get_pipe_release(device);
 } else {
 BASEBUF_REGISTER_UPDATE(This);
 }
diff --git a/src/gallium/state_trackers/nine/nine_state.c 
b/src/gallium/state_trackers/nine/nine_state.c
index 0cf3721..4783599 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -2682,11 +2682,13 @@ CSMT_ITEM_NO_WAIT(nine_context_blit,
 struct pipe_query *
 nine_context_create_query(struct NineDevice9 *device, unsigned query_type)
 {
-struct nine_context *context = >context;
+struct pipe_context *pipe;
+struct pipe_query *res;
 
-if (device->csmt_active)
-nine_csmt_process(device);
-return context->pipe->create_query(context->pipe, query_type, 0);
+pipe = nine_context_get_pipe_acquire(device);
+res = pipe->create_query(pipe, query_type, 0);
+nine_context_get_pipe_release(device);
+return res;
 }
 
 CSMT_ITEM_DO_WAIT(nine_context_destroy_query,
@@ -3150,7 +3152,7 @@ update_vertex_elements_sw(struct NineDevice9 *device)
 static void
 update_vertex_buffers_sw(struct NineDevice9 *device, int start_vertice, int 
num_vertices)
 {
-struct pipe_context *pipe = NineDevice9_GetPipe(device);
+struct pipe_context *pipe = nine_context_get_pipe_acquire(device);
 struct pipe_context *pipe_sw = device->pipe_sw;
 struct nine_state *state = >state;
 struct nine_state_sw_internal *sw_internal = >state_sw_internal;
@@ -3198,6 +3200,7 @@ update_vertex_buffers_sw(struct NineDevice9 *device, int 
start_vertice, int num_
 pipe_sw->set_vertex_buffers(pipe_sw, i, 1, NULL);
 }
 }
+nine_context_get_pipe_release(device);
 }
 
 static void
@@ -3375,7 +3378,7 @@ void
 nine_state_after_draw_sw(struct NineDevice9 *device)
 {
 struct nine_state_sw_internal *sw_internal = 

[Mesa-dev] [PATCH 69/84] st/nine: Implement nine_context_range_upload

2016-12-07 Thread Axel Davy
Will be used to upload buffers.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_state.c | 11 +++
 src/gallium/state_trackers/nine/nine_state.h |  8 
 2 files changed, 19 insertions(+)

diff --git a/src/gallium/state_trackers/nine/nine_state.c 
b/src/gallium/state_trackers/nine/nine_state.c
index 75ebcf3..53ff1d5 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -2696,6 +2696,17 @@ CSMT_ITEM_NO_WAIT(nine_context_clear_render_target,
 context->pipe->clear_render_target(context->pipe, surf, , x, y, 
width, height, false);
 }
 
+CSMT_ITEM_NO_WAIT_WITH_COUNTER(nine_context_range_upload,
+   ARG_BIND_RES(struct pipe_resource, res),
+   ARG_VAL(unsigned, offset),
+   ARG_VAL(unsigned, size),
+   ARG_VAL(const void *, data))
+{
+struct nine_context *context = >context;
+
+context->pipe->buffer_subdata(context->pipe, res, 0, offset, size, data);
+}
+
 struct pipe_query *
 nine_context_create_query(struct NineDevice9 *device, unsigned query_type)
 {
diff --git a/src/gallium/state_trackers/nine/nine_state.h 
b/src/gallium/state_trackers/nine/nine_state.h
index 6578be3..c0afbe0 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -539,6 +539,14 @@ nine_context_clear_render_target(struct NineDevice9 
*device,
  UINT width,
  UINT height);
 
+void
+nine_context_range_upload(struct NineDevice9 *device,
+  unsigned *counter,
+  struct pipe_resource *res,
+  unsigned offset,
+  unsigned size,
+  const void *data);
+
 struct pipe_query *
 nine_context_create_query(struct NineDevice9 *device, unsigned query_type);
 
-- 
2.10.2

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


[Mesa-dev] [PATCH 82/84] st/nine: Do not wait for DEFAULT lock for volumes when we can

2016-12-07 Thread Axel Davy
If the volumes (and the texture container) are not referenced,
then they are no pending operations on them. We can lock directly.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/volume9.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/volume9.c 
b/src/gallium/state_trackers/nine/volume9.c
index 29a1fcb..11236a0 100644
--- a/src/gallium/state_trackers/nine/volume9.c
+++ b/src/gallium/state_trackers/nine/volume9.c
@@ -320,10 +320,17 @@ NineVolume9_LockBox( struct NineVolume9 *This,
 pLockedVolume->pBits =
 NineVolume9_GetSystemMemPointer(This, box.x, box.y, box.z);
 } else {
-pipe = NineDevice9_GetPipe(This->base.device);
+bool no_refs = !p_atomic_read(>base.bind) &&
+!p_atomic_read(>base.container->bind);
+if (no_refs)
+pipe = nine_context_get_pipe_acquire(This->base.device);
+else
+pipe = NineDevice9_GetPipe(This->base.device);
 pLockedVolume->pBits =
 pipe->transfer_map(pipe, resource, This->level, usage,
, >transfer);
+if (no_refs)
+nine_context_get_pipe_release(This->base.device);
 if (!This->transfer) {
 if (Flags & D3DLOCK_DONOTWAIT)
 return D3DERR_WASSTILLDRAWING;
-- 
2.10.2

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


[Mesa-dev] [PATCH 81/84] st/nine: Do not wait for DEFAULT lock for surfaces when we can

2016-12-07 Thread Axel Davy
If the surfaces (and the texture container) are not referenced,
then they are no pending operations on them. We can lock directly.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/surface9.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/surface9.c 
b/src/gallium/state_trackers/nine/surface9.c
index 26c2d69..a5c4a9e 100644
--- a/src/gallium/state_trackers/nine/surface9.c
+++ b/src/gallium/state_trackers/nine/surface9.c
@@ -20,6 +20,7 @@
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
+#include "iunknown.h"
 #include "surface9.h"
 #include "device9.h"
 
@@ -479,13 +480,22 @@ NineSurface9_LockRect( struct NineSurface9 *This,
   box.y);
 }
 } else {
+bool no_refs = !p_atomic_read(>base.base.bind) &&
+!(This->base.base.container && 
p_atomic_read(>base.base.container->bind));
 DBG("mapping pipe_resource %p (level=%u usage=%x)\n",
 resource, This->level, usage);
 
-pipe = NineDevice9_GetPipe(This->base.base.device);
+/* if the object is not bound internally, there can't be any pending
+ * operation with the surface in the queue */
+if (no_refs)
+pipe = nine_context_get_pipe_acquire(This->base.base.device);
+else
+pipe = NineDevice9_GetPipe(This->base.base.device);
 pLockedRect->pBits = pipe->transfer_map(pipe, resource,
 This->level, usage, ,
 >transfer);
+if (no_refs)
+nine_context_get_pipe_release(This->base.base.device);
 if (!This->transfer) {
 DBG("transfer_map failed\n");
 if (Flags & D3DLOCK_DONOTWAIT)
-- 
2.10.2

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


[Mesa-dev] [PATCH 74/84] st/nine: Use nine_context_box_upload for surfaces

2016-12-07 Thread Axel Davy
Use nine_context_box_upload for uploads:
. systemmem surface to default surface
. managed surface internal content to its resource.

Check the uploads are executed before any action
that can alter the data, that is LockRect,
NineSurface9_CopyDefaultToMem and surface destruction.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/surface9.c | 63 +++---
 src/gallium/state_trackers/nine/surface9.h |  2 +
 2 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/src/gallium/state_trackers/nine/surface9.c 
b/src/gallium/state_trackers/nine/surface9.c
index 6373f69..f7e479a 100644
--- a/src/gallium/state_trackers/nine/surface9.c
+++ b/src/gallium/state_trackers/nine/surface9.c
@@ -205,6 +205,9 @@ NineSurface9_dtor( struct NineSurface9 *This )
 if (This->transfer)
 NineSurface9_UnlockRect(This);
 
+if (p_atomic_read(>pending_uploads_counter))
+nine_csmt_process(This->base.base.device);
+
 pipe_surface_reference(>surface[0], NULL);
 pipe_surface_reference(>surface[1], NULL);
 
@@ -452,6 +455,9 @@ NineSurface9_LockRect( struct NineSurface9 *This,
 
 user_warn(This->desc.Format == D3DFMT_NULL);
 
+if (p_atomic_read(>pending_uploads_counter))
+nine_csmt_process(This->base.base.device);
+
 if (This->data_conversion) {
 /* For now we only have uncompressed formats here */
 pLockedRect->Pitch = This->stride_conversion;
@@ -588,11 +594,8 @@ NineSurface9_CopyMemToDefault( struct NineSurface9 *This,
const POINT *pDestPoint,
const RECT *pSourceRect )
 {
-struct pipe_context *pipe;
-struct pipe_transfer *transfer = NULL;
 struct pipe_resource *r_dst = This->base.resource;
-struct pipe_box dst_box;
-uint8_t *map = NULL;
+struct pipe_box dst_box, src_box;
 int src_x, src_y, dst_x, dst_y, copy_width, copy_height;
 
 assert(This->base.pool == D3DPOOL_DEFAULT &&
@@ -620,27 +623,18 @@ NineSurface9_CopyMemToDefault( struct NineSurface9 *This,
 
 u_box_2d_zslice(dst_x, dst_y, This->layer,
 copy_width, copy_height, _box);
-
-pipe = NineDevice9_GetPipe(This->base.base.device);
-map = pipe->transfer_map(pipe,
- r_dst,
- This->level,
- PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
- _box, );
-if (!map)
-return;
-
-/* Note: if formats are the sames, it will revert
- * to normal memcpy */
-(void) util_format_translate(r_dst->format,
- map, transfer->stride,
- 0, 0,
- From->base.info.format,
- From->data, From->stride,
- src_x, src_y,
- copy_width, copy_height);
-
-pipe_transfer_unmap(pipe, transfer);
+u_box_2d_zslice(src_x, src_y, 0,
+copy_width, copy_height, _box);
+
+nine_context_box_upload(This->base.base.device,
+>pending_uploads_counter,
+r_dst,
+This->level,
+_box,
+From->base.info.format,
+From->data, From->stride,
+0, /* depth = 1 */
+_box);
 
 if (This->data_conversion)
 (void) util_format_translate(This->format_conversion,
@@ -675,6 +669,9 @@ NineSurface9_CopyDefaultToMem( struct NineSurface9 *This,
 u_box_origin_2d(This->desc.Width, This->desc.Height, _box);
 src_box.z = From->layer;
 
+if (p_atomic_read(>pending_uploads_counter))
+nine_csmt_process(This->base.base.device);
+
 pipe = NineDevice9_GetPipe(This->base.base.device);
 p_src = pipe->transfer_map(pipe, r_src, From->level,
PIPE_TRANSFER_READ,
@@ -700,9 +697,7 @@ HRESULT
 NineSurface9_UploadSelf( struct NineSurface9 *This,
  const struct pipe_box *damaged )
 {
-struct pipe_context *pipe;
 struct pipe_resource *res = This->base.resource;
-uint8_t *ptr;
 struct pipe_box box;
 
 DBG("This=%p damaged=%p\n", This, damaged);
@@ -722,11 +717,15 @@ NineSurface9_UploadSelf( struct NineSurface9 *This,
 box.depth = 1;
 }
 
-ptr = NineSurface9_GetSystemMemPointer(This, box.x, box.y);
-
-pipe = NineDevice9_GetPipe(This->base.base.device);
-pipe->texture_subdata(pipe, res, This->level, 0,
-  , ptr, This->stride, 0);
+nine_context_box_upload(This->base.base.device,
+>pending_uploads_counter,
+res,
+This->level,
+,
+res->format,
+   

[Mesa-dev] [PATCH 83/84] st/nine: Allow non-zero resource offset for vertex buffers

2016-12-07 Thread Axel Davy
Next patches will introduce an offset.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_state.c| 15 +--
 src/gallium/state_trackers/nine/vertexbuffer9.c |  3 ++-
 src/gallium/state_trackers/nine/vertexbuffer9.h |  2 +-
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_state.c 
b/src/gallium/state_trackers/nine/nine_state.c
index 3c3a2ac..5b9d5e7 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -1539,14 +1539,15 @@ nine_context_set_stream_source(struct NineDevice9 
*device,
UINT Stride)
 {
 struct pipe_resource *res = NULL;
+unsigned offset = 0;
 
 if (pVBuf9)
-res = NineVertexBuffer9_GetResource(pVBuf9);
+res = NineVertexBuffer9_GetResource(pVBuf9, );
 /* in the future when there is internal offset, add it
  * to OffsetInBytes */
 
 nine_context_set_stream_source_apply(device, StreamNumber,
- res, OffsetInBytes,
+ res, offset + OffsetInBytes,
  Stride);
 }
 
@@ -2040,9 +2041,10 @@ nine_context_apply_stateblock(struct NineDevice9 *device,
 for (i = 0; m; ++i, m >>= 1) {
 if (src->changed.vtxbuf & (1 << i)) {
 if (src->stream[i]) {
-context->vtxbuf[i].buffer_offset = 
src->vtxbuf[i].buffer_offset;
+unsigned offset = 0;
 pipe_resource_reference(>vtxbuf[i].buffer,
-src->stream[i] ? 
NineVertexBuffer9_GetResource(src->stream[i]) : NULL);
+src->stream[i] ? 
NineVertexBuffer9_GetResource(src->stream[i], ) : NULL);
+context->vtxbuf[i].buffer_offset = 
src->vtxbuf[i].buffer_offset + offset;
 context->vtxbuf[i].stride = src->vtxbuf[i].stride;
 }
 }
@@ -3280,16 +3282,17 @@ update_vertex_buffers_sw(struct NineDevice9 *device, 
int start_vertice, int num_
 for (i = 0; mask; mask >>= 1, ++i) {
 if (mask & 1) {
 if (state->stream[i]) {
+unsigned offset;
 struct pipe_resource *buf;
 struct pipe_box box;
 
 vtxbuf = state->vtxbuf[i];
-vtxbuf.buffer = 
NineVertexBuffer9_GetResource(state->stream[i]);
+vtxbuf.buffer = 
NineVertexBuffer9_GetResource(state->stream[i], );
 
 DBG("Locking %p (offset %d, length %d)\n", vtxbuf.buffer,
 vtxbuf.buffer_offset, num_vertices * vtxbuf.stride);
 
-u_box_1d(vtxbuf.buffer_offset + start_vertice * vtxbuf.stride,
+u_box_1d(vtxbuf.buffer_offset + offset + start_vertice * 
vtxbuf.stride,
  num_vertices * vtxbuf.stride, );
 buf = vtxbuf.buffer;
 vtxbuf.user_buffer = pipe->transfer_map(pipe, buf, 0, 
PIPE_TRANSFER_READ, ,
diff --git a/src/gallium/state_trackers/nine/vertexbuffer9.c 
b/src/gallium/state_trackers/nine/vertexbuffer9.c
index b0eebfb..027f290 100644
--- a/src/gallium/state_trackers/nine/vertexbuffer9.c
+++ b/src/gallium/state_trackers/nine/vertexbuffer9.c
@@ -63,8 +63,9 @@ NineVertexBuffer9_dtor( struct NineVertexBuffer9 *This )
 }
 
 struct pipe_resource *
-NineVertexBuffer9_GetResource( struct NineVertexBuffer9 *This )
+NineVertexBuffer9_GetResource( struct NineVertexBuffer9 *This, unsigned 
*offset )
 {
+*offset = 0;
 return NineBuffer9_GetResource(>base);
 }
 
diff --git a/src/gallium/state_trackers/nine/vertexbuffer9.h 
b/src/gallium/state_trackers/nine/vertexbuffer9.h
index 6caa9bf..2991dba 100644
--- a/src/gallium/state_trackers/nine/vertexbuffer9.h
+++ b/src/gallium/state_trackers/nine/vertexbuffer9.h
@@ -58,7 +58,7 @@ NineVertexBuffer9_dtor( struct NineVertexBuffer9 *This );
 /*** Nine private ***/
 
 struct pipe_resource *
-NineVertexBuffer9_GetResource( struct NineVertexBuffer9 *This );
+NineVertexBuffer9_GetResource( struct NineVertexBuffer9 *This, unsigned 
*offset );
 
 /*** Direct3D public ***/
 
-- 
2.10.2

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


[Mesa-dev] [PATCH 61/84] st/nine: Use nine_context_clear_render_target

2016-12-07 Thread Axel Davy
Enables to not wait for the worker thread for ColorFill.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/device9.c|  7 +--
 src/gallium/state_trackers/nine/nine_state.c | 17 +
 src/gallium/state_trackers/nine/nine_state.h |  9 +
 src/gallium/state_trackers/nine/surface9.c   | 11 ++-
 4 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/src/gallium/state_trackers/nine/device9.c 
b/src/gallium/state_trackers/nine/device9.c
index d5a2aed..bb3ad9b 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -1752,11 +1752,8 @@ NineDevice9_ColorFill( struct NineDevice9 *This,
const RECT *pRect,
D3DCOLOR color )
 {
-struct pipe_context *pipe = NineDevice9_GetPipe(This);
 struct NineSurface9 *surf = NineSurface9(pSurface);
-struct pipe_surface *psurf;
 unsigned x, y, w, h;
-union pipe_color_union rgba;
 
 DBG("This=%p pSurface=%p pRect=%p color=%08x\n", This,
 pSurface, pRect, color);
@@ -1790,11 +1787,9 @@ NineDevice9_ColorFill( struct NineDevice9 *This,
 w = surf->desc.Width;
 h = surf->desc.Height;
 }
-d3dcolor_to_pipe_color_union(, color);
 
 if (surf->base.info.bind & PIPE_BIND_RENDER_TARGET) {
-psurf = NineSurface9_GetSurface(surf, 0);
-pipe->clear_render_target(pipe, psurf, , x, y, w, h, false);
+nine_context_clear_render_target(This, surf, color, x, y, w, h);
 } else {
 D3DLOCKED_RECT lock;
 union util_color uc;
diff --git a/src/gallium/state_trackers/nine/nine_state.c 
b/src/gallium/state_trackers/nine/nine_state.c
index 4783599..265fde8 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -2679,6 +2679,23 @@ CSMT_ITEM_NO_WAIT(nine_context_blit,
 context->pipe->blit(context->pipe, blit);
 }
 
+CSMT_ITEM_NO_WAIT(nine_context_clear_render_target,
+  ARG_BIND_REF(struct NineSurface9, surface),
+  ARG_VAL(D3DCOLOR, color),
+  ARG_VAL(UINT, x),
+  ARG_VAL(UINT, y),
+  ARG_VAL(UINT, width),
+  ARG_VAL(UINT, height))
+{
+struct nine_context *context = >context;
+struct pipe_surface *surf;
+union pipe_color_union rgba;
+
+d3dcolor_to_pipe_color_union(, color);
+surf = NineSurface9_GetSurface(surface, 0);
+context->pipe->clear_render_target(context->pipe, surf, , x, y, 
width, height, false);
+}
+
 struct pipe_query *
 nine_context_create_query(struct NineDevice9 *device, unsigned query_type)
 {
diff --git a/src/gallium/state_trackers/nine/nine_state.h 
b/src/gallium/state_trackers/nine/nine_state.h
index 912395d..421f8f9 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -530,6 +530,15 @@ void
 nine_context_blit(struct NineDevice9 *device,
   struct pipe_blit_info *blit);
 
+void
+nine_context_clear_render_target(struct NineDevice9 *device,
+ struct NineSurface9 *surface,
+ D3DCOLOR color,
+ UINT x,
+ UINT y,
+ UINT width,
+ UINT height);
+
 struct pipe_query *
 nine_context_create_query(struct NineDevice9 *device, unsigned query_type);
 
diff --git a/src/gallium/state_trackers/nine/surface9.c 
b/src/gallium/state_trackers/nine/surface9.c
index ca9fd55..6373f69 100644
--- a/src/gallium/state_trackers/nine/surface9.c
+++ b/src/gallium/state_trackers/nine/surface9.c
@@ -55,9 +55,6 @@ NineSurface9_ctor( struct NineSurface9 *This,
D3DSURFACE_DESC *pDesc )
 {
 HRESULT hr;
-union pipe_color_union rgba = {0};
-struct pipe_surface *surf;
-struct pipe_context *pipe;
 bool allocate = !pContainer && pDesc->Format != D3DFMT_NULL;
 D3DMULTISAMPLE_TYPE multisample_type;
 
@@ -192,12 +189,8 @@ NineSurface9_ctor( struct NineSurface9 *This,
 }
 
 /* TODO: investigate what else exactly needs to be cleared */
-if (This->base.resource && (pDesc->Usage & D3DUSAGE_RENDERTARGET)) {
-surf = NineSurface9_GetSurface(This, 0);
-pipe = nine_context_get_pipe_acquire(pParams->device);
-pipe->clear_render_target(pipe, surf, , 0, 0, pDesc->Width, 
pDesc->Height, false);
-nine_context_get_pipe_release(pParams->device);
-}
+if (This->base.resource && (pDesc->Usage & D3DUSAGE_RENDERTARGET))
+nine_context_clear_render_target(pParams->device, This, 0, 0, 0, 
pDesc->Width, pDesc->Height);
 
 NineSurface9_Dump(This);
 
-- 
2.10.2

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


[Mesa-dev] [PATCH 77/84] st/nine: Use nine_context_box_upload for volumes

2016-12-07 Thread Axel Davy
Use nine_context_box_upload for uploads:
. systemmem volume to default volume
. managed volume internal content to its resource.

Check the uploads are executed before any action
that can alter the data, that is LockBox and
volume destruction.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/volume9.c | 60 +--
 src/gallium/state_trackers/nine/volume9.h |  2 ++
 2 files changed, 26 insertions(+), 36 deletions(-)

diff --git a/src/gallium/state_trackers/nine/volume9.c 
b/src/gallium/state_trackers/nine/volume9.c
index b579f92..e8abfe7 100644
--- a/src/gallium/state_trackers/nine/volume9.c
+++ b/src/gallium/state_trackers/nine/volume9.c
@@ -145,6 +145,9 @@ NineVolume9_dtor( struct NineVolume9 *This )
 if (This->transfer)
 NineVolume9_UnlockBox(This);
 
+if (p_atomic_read(>pending_uploads_counter))
+nine_csmt_process(This->base.device);
+
 if (This->data)
 align_free(This->data);
 if (This->data_conversion)
@@ -301,6 +304,9 @@ NineVolume9_LockBox( struct NineVolume9 *This,
  );
 }
 
+if (p_atomic_read(>pending_uploads_counter))
+nine_csmt_process(This->base.device);
+
 if (This->data_conversion) {
 /* For now we only have uncompressed formats here */
 pLockedVolume->RowPitch = This->stride_conversion;
@@ -398,12 +404,9 @@ NineVolume9_CopyMemToDefault( struct NineVolume9 *This,
   unsigned dstx, unsigned dsty, unsigned dstz,
   struct pipe_box *pSrcBox )
 {
-struct pipe_context *pipe;
-struct pipe_transfer *transfer = NULL;
 struct pipe_resource *r_dst = This->resource;
 struct pipe_box src_box;
 struct pipe_box dst_box;
-uint8_t *map = NULL;
 
 DBG("This=%p From=%p dstx=%u dsty=%u dstz=%u pSrcBox=%p\n",
 This, From, dstx, dsty, dstz, pSrcBox);
@@ -430,32 +433,15 @@ NineVolume9_CopyMemToDefault( struct NineVolume9 *This,
 dst_box.height = src_box.height;
 dst_box.depth = src_box.depth;
 
-pipe = NineDevice9_GetPipe(This->base.device);
-
-map = pipe->transfer_map(pipe,
- r_dst,
- This->level,
- PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
- _box, );
-if (!map)
-return;
-
-/* Note: if formats are the sames, it will revert
- * to normal memcpy */
-(void) util_format_translate_3d(r_dst->format,
-map, transfer->stride,
-transfer->layer_stride,
-0, 0, 0,
-From->info.format,
-From->data, From->stride,
-From->layer_stride,
-src_box.x, src_box.y,
-src_box.z,
-src_box.width,
-src_box.height,
-src_box.depth);
-
-pipe_transfer_unmap(pipe, transfer);
+nine_context_box_upload(This->base.device,
+>pending_uploads_counter,
+r_dst,
+This->level,
+_box,
+From->info.format,
+From->data, From->stride,
+From->layer_stride,
+_box);
 
 if (This->data_conversion)
 (void) util_format_translate_3d(This->format_conversion,
@@ -481,10 +467,8 @@ HRESULT
 NineVolume9_UploadSelf( struct NineVolume9 *This,
 const struct pipe_box *damaged )
 {
-struct pipe_context *pipe;
 struct pipe_resource *res = This->resource;
 struct pipe_box box;
-uint8_t *ptr;
 
 DBG("This=%p damaged=%p data=%p res=%p\n", This, damaged,
 This->data, res);
@@ -503,11 +487,15 @@ NineVolume9_UploadSelf( struct NineVolume9 *This,
 box.depth = This->desc.Depth;
 }
 
-ptr = NineVolume9_GetSystemMemPointer(This, box.x, box.y, box.z);
-
-pipe = NineDevice9_GetPipe(This->base.device);
-pipe->texture_subdata(pipe, res, This->level, 0, ,
-  ptr, This->stride, This->layer_stride);
+nine_context_box_upload(This->base.device,
+>pending_uploads_counter,
+res,
+This->level,
+,
+res->format,
+This->data, This->stride,
+This->layer_stride,
+);
 
 return D3D_OK;
 }
diff --git a/src/gallium/state_trackers/nine/volume9.h 
b/src/gallium/state_trackers/nine/volume9.h
index 5bddf8f..e84119f 100644
--- 

[Mesa-dev] [PATCH 80/84] st/nine: Add arguments to context's blit and copy_region

2016-12-07 Thread Axel Davy
The new arguments enable to reference the objects while
the function hasn't run.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/device9.c| 14 --
 src/gallium/state_trackers/nine/nine_state.c | 10 ++
 src/gallium/state_trackers/nine/nine_state.h |  4 
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/nine/device9.c 
b/src/gallium/state_trackers/nine/device9.c
index bb3ad9b..91f09de 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -1723,7 +1723,8 @@ NineDevice9_StretchRect( struct NineDevice9 *This,
 PIPE_BIND_RENDER_TARGET),
 D3DERR_INVALIDCALL);
 
-nine_context_blit(This, );
+nine_context_blit(This, (struct NineUnknown *)dst,
+  (struct NineUnknown *)src, );
 } else {
 assert(blit.dst.box.x >= 0 && blit.dst.box.y >= 0 &&
blit.src.box.x >= 0 && blit.src.box.y >= 0 &&
@@ -1733,11 +1734,12 @@ NineDevice9_StretchRect( struct NineDevice9 *This,
blit.src.box.y + blit.src.box.height <= src->desc.Height);
 /* Or drivers might crash ... */
 DBG("Using resource_copy_region.\n");
-nine_context_resource_copy_region(This,
-blit.dst.resource, blit.dst.level,
-,
-blit.src.resource, blit.src.level,
-);
+nine_context_resource_copy_region(This, (struct NineUnknown *)dst,
+  (struct NineUnknown *)src,
+  blit.dst.resource, blit.dst.level,
+  ,
+  blit.src.resource, blit.src.level,
+  );
 }
 
 /* Communicate the container it needs to update sublevels - if apply */
diff --git a/src/gallium/state_trackers/nine/nine_state.c 
b/src/gallium/state_trackers/nine/nine_state.c
index f0eb23d..3c3a2ac 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -2656,6 +2656,8 @@ 
CSMT_ITEM_NO_WAIT(nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf,
 }
 
 CSMT_ITEM_NO_WAIT(nine_context_resource_copy_region,
+  ARG_BIND_REF(struct NineUnknown, dst),
+  ARG_BIND_REF(struct NineUnknown, src),
   ARG_BIND_RES(struct pipe_resource, dst_res),
   ARG_VAL(unsigned, dst_level),
   ARG_COPY_REF(struct pipe_box, dst_box),
@@ -2665,6 +2667,9 @@ CSMT_ITEM_NO_WAIT(nine_context_resource_copy_region,
 {
 struct nine_context *context = >context;
 
+(void) dst;
+(void) src;
+
 context->pipe->resource_copy_region(context->pipe,
 dst_res, dst_level,
 dst_box->x, dst_box->y, dst_box->z,
@@ -2673,10 +2678,15 @@ CSMT_ITEM_NO_WAIT(nine_context_resource_copy_region,
 }
 
 CSMT_ITEM_NO_WAIT(nine_context_blit,
+  ARG_BIND_REF(struct NineUnknown, dst),
+  ARG_BIND_REF(struct NineUnknown, src),
   ARG_BIND_BLIT(struct pipe_blit_info, blit))
 {
 struct nine_context *context = >context;
 
+(void) dst;
+(void) src;
+
 context->pipe->blit(context->pipe, blit);
 }
 
diff --git a/src/gallium/state_trackers/nine/nine_state.h 
b/src/gallium/state_trackers/nine/nine_state.h
index 68dca40..a487d8c 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -519,6 +519,8 @@ 
nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(struct NineDevice9 *devic
 
 void
 nine_context_resource_copy_region(struct NineDevice9 *device,
+  struct NineUnknown *dst,
+  struct NineUnknown *src,
   struct pipe_resource* dst_res,
   unsigned dst_level,
   const struct pipe_box *dst_box,
@@ -528,6 +530,8 @@ nine_context_resource_copy_region(struct NineDevice9 
*device,
 
 void
 nine_context_blit(struct NineDevice9 *device,
+  struct NineUnknown *dst,
+  struct NineUnknown *src,
   struct pipe_blit_info *blit);
 
 void
-- 
2.10.2

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


[Mesa-dev] [PATCH 66/84] st/nine: Detach buffers in swapchain dtor.

2016-12-07 Thread Axel Davy
BackBuffers can survive swapchain dtor if
the user has a reference on them.

The swapchain itself has no reference on the buffer.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/swapchain9.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/swapchain9.c 
b/src/gallium/state_trackers/nine/swapchain9.c
index 75e0345..6fb3dfc 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -508,7 +508,7 @@ NineSwapChain9_dtor( struct NineSwapChain9 *This )
 
 for (i = 0; i < This->num_back_buffers; i++) {
 if (This->buffers[i])
-NineUnknown_Release(NineUnknown(This->buffers[i]));
+NineUnknown_Detach(NineUnknown(This->buffers[i]));
 if (This->present_handles[i])
 ID3DPresent_DestroyD3DWindowBuffer(This->present, 
This->present_handles[i]);
 if (This->present_buffers[i])
-- 
2.10.2

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


[Mesa-dev] [PATCH 31/84] st/nine: Rename pipe to pipe_data in nine_context

2016-12-07 Thread Axel Davy
This patch it to avoid name conflict when device->pipe
will be moved to nine_context.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_ff.c| 20 +++
 src/gallium/state_trackers/nine/nine_state.c | 90 ++--
 src/gallium/state_trackers/nine/nine_state.h |  2 +-
 3 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c 
b/src/gallium/state_trackers/nine/nine_ff.c
index 748a9fa..e168bf8 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -2062,18 +2062,18 @@ nine_ff_update(struct NineDevice9 *device)
 cb.buffer_size = NINE_FF_NUM_VS_CONST * 4 * sizeof(float);
 
 if (!device->driver_caps.user_cbufs) {
-context->pipe.cb_vs_ff.buffer_size = cb.buffer_size;
+context->pipe_data.cb_vs_ff.buffer_size = cb.buffer_size;
 u_upload_data(device->constbuf_uploader,
   0,
   cb.buffer_size,
   device->constbuf_alignment,
   cb.user_buffer,
-  >pipe.cb_vs_ff.buffer_offset,
-  >pipe.cb_vs_ff.buffer);
+  >pipe_data.cb_vs_ff.buffer_offset,
+  >pipe_data.cb_vs_ff.buffer);
 u_upload_unmap(device->constbuf_uploader);
-context->pipe.cb_vs_ff.user_buffer = NULL;
+context->pipe_data.cb_vs_ff.user_buffer = NULL;
 } else
-context->pipe.cb_vs_ff = cb;
+context->pipe_data.cb_vs_ff = cb;
 context->commit |= NINE_STATE_COMMIT_CONST_VS;
 }
 
@@ -2086,18 +2086,18 @@ nine_ff_update(struct NineDevice9 *device)
 cb.buffer_size = NINE_FF_NUM_PS_CONST * 4 * sizeof(float);
 
 if (!device->driver_caps.user_cbufs) {
-context->pipe.cb_ps_ff.buffer_size = cb.buffer_size;
+context->pipe_data.cb_ps_ff.buffer_size = cb.buffer_size;
 u_upload_data(device->constbuf_uploader,
   0,
   cb.buffer_size,
   device->constbuf_alignment,
   cb.user_buffer,
-  >pipe.cb_ps_ff.buffer_offset,
-  >pipe.cb_ps_ff.buffer);
+  >pipe_data.cb_ps_ff.buffer_offset,
+  >pipe_data.cb_ps_ff.buffer);
 u_upload_unmap(device->constbuf_uploader);
-context->pipe.cb_ps_ff.user_buffer = NULL;
+context->pipe_data.cb_ps_ff.user_buffer = NULL;
 } else
-context->pipe.cb_ps_ff = cb;
+context->pipe_data.cb_ps_ff = cb;
 context->commit |= NINE_STATE_COMMIT_CONST_PS;
 }
 
diff --git a/src/gallium/state_trackers/nine/nine_state.c 
b/src/gallium/state_trackers/nine/nine_state.c
index 22255f2..d294fd8 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -64,21 +64,21 @@ check_multisample(struct NineDevice9 *device)
 static inline void
 prepare_blend(struct NineDevice9 *device)
 {
-nine_convert_blend_state(>context.pipe.blend, device->context.rs);
+nine_convert_blend_state(>context.pipe_data.blend, 
device->context.rs);
 device->context.commit |= NINE_STATE_COMMIT_BLEND;
 }
 
 static inline void
 prepare_dsa(struct NineDevice9 *device)
 {
-nine_convert_dsa_state(>context.pipe.dsa, device->context.rs);
+nine_convert_dsa_state(>context.pipe_data.dsa, device->context.rs);
 device->context.commit |= NINE_STATE_COMMIT_DSA;
 }
 
 static inline void
 prepare_rasterizer(struct NineDevice9 *device)
 {
-nine_convert_rasterizer_state(device, >context.pipe.rast, 
device->context.rs);
+nine_convert_rasterizer_state(device, >context.pipe_data.rast, 
device->context.rs);
 device->context.commit |= NINE_STATE_COMMIT_RASTERIZER;
 }
 
@@ -114,14 +114,14 @@ prepare_vs_constants_userbuf_swvp(struct NineDevice9 
*device)
 /* Do not erase the buffer field.
  * It is either NULL (user_cbufs), or a resource.
  * u_upload_data will do the proper refcount */
-context->pipe.cb0_swvp.buffer_offset = cb.buffer_offset;
-context->pipe.cb0_swvp.buffer_size = cb.buffer_size;
-context->pipe.cb0_swvp.user_buffer = cb.user_buffer;
+context->pipe_data.cb0_swvp.buffer_offset = cb.buffer_offset;
+context->pipe_data.cb0_swvp.buffer_size = cb.buffer_size;
+context->pipe_data.cb0_swvp.user_buffer = cb.user_buffer;
 
 cb.user_buffer = (char *)cb.user_buffer + 4096 * sizeof(float[4]);
-context->pipe.cb1_swvp.buffer_offset = cb.buffer_offset;
-context->pipe.cb1_swvp.buffer_size = cb.buffer_size;
-context->pipe.cb1_swvp.user_buffer = cb.user_buffer;
+context->pipe_data.cb1_swvp.buffer_offset = cb.buffer_offset;
+

  1   2   3   >