Re: [Mesa-dev] [PATCH 5/5] st/mesa: move all sampler view code into new st_sampler_view.[ch] files

2016-10-05 Thread Brian Paul


I found a problem with texture buffers that I missed before.  We need to 
discard the texture's sampler view if the texture buffer offset/size 
params change.  The cleanest way to tell the state tracker about this is 
to use the ctx->Driver.TexParameter() callback.  I've made that change, 
retested with piglit and will post the updated series soon.


-Brian

On 10/03/2016 09:21 AM, Brian Paul wrote:

Actually, I just need to bracket some of the assertions with the test
for GL_TEXTURE_BUFFER.  I'll make that change and re-test before
pushing.  I suspect I did my piglit run w/ a release build on Windows.

Thanks for reviewing.

-Brian

On 10/02/2016 02:53 PM, Marek Olšák wrote:

One more fix for TBOs is needed:

diff --git a/src/mesa/state_tracker/st_sampler_view.c
b/src/mesa/state_tracker/st_sampler_view.c
index da1df86..a0bea46 100644
--- a/src/mesa/state_tracker/st_sampler_view.c
+++ b/src/mesa/state_tracker/st_sampler_view.c
@@ -459,7 +459,7 @@ st_get_texture_sampler_view_from_stobj(struct
st_context *st,

 sv = st_texture_get_sampler_view(st, stObj);

-   if (*sv) {
+   if (*sv && stObj->base.Target != GL_TEXTURE_BUFFER) {
/* Debug check: make sure that the sampler view's parameters are
 * what they're supposed to be.
 */

If fixes this assertion failure:
arb_texture_buffer_range-ranges: state_tracker/st_sampler_view.c:472:
st_get_texture_sampler_view_from_stobj: Assertion `last_level(stObj)
== view->u.tex.last_level' failed.

Marek


On Sun, Oct 2, 2016 at 10:31 PM, Marek Olšák  wrote:

FYI, the series breaks this test:

piglit/bin/glsl-resource-not-bound Buffer -auto -fbo
glsl-resource-not-bound: state_tracker/st_sampler_view.c:456:
st_get_texture_sampler_view_from_stobj: Assertion `stObj->pt' failed.
Aborted

Removing the assertion fixes it. Note that empty TBO slots are NULL.

Marek



On Sun, Oct 2, 2016 at 2:29 PM, Marek Olšák  wrote:

You also need this:

diff --git a/src/mesa/state_tracker/st_vdpau.c
b/src/mesa/state_tracker/st_vdpau.c
index 4f599dd..cafbd3d 100644
--- a/src/mesa/state_tracker/st_vdpau.c
+++ b/src/mesa/state_tracker/st_vdpau.c
@@ -44,6 +44,7 @@
  #include "st_vdpau.h"
  #include "st_context.h"
  #include "st_texture.h"
+#include "st_sampler_view.h"
  #include "st_format.h"
  #include "st_cb_flush.h"

With that fixed, the series is:

Reviewed-by: Marek Olšák 

Marek



On Sat, Oct 1, 2016 at 12:53 AM, Brian Paul  wrote:

Previously, the sampler view code was scattered across several
different
files.

Note, the previous REALLOC(), FREE() for
st_texture_object::sampler_views
are replaced by realloc(), free() to avoid conflicting macros in
Mesa vs.
Gallium.
---
  src/mesa/Makefile.sources  |   2 +
  src/mesa/state_tracker/st_atom_pixeltransfer.c |   1 +
  src/mesa/state_tracker/st_atom_texture.c   | 358
+-
  src/mesa/state_tracker/st_cb_bitmap.c  |   1 +
  src/mesa/state_tracker/st_cb_drawpixels.c  |   1 +
  src/mesa/state_tracker/st_cb_eglimage.c|   2 +
  src/mesa/state_tracker/st_cb_texture.c |   1 +
  src/mesa/state_tracker/st_context.c|   1 +
  src/mesa/state_tracker/st_sampler_view.c   | 487
+
  src/mesa/state_tracker/st_sampler_view.h   |  83 +
  src/mesa/state_tracker/st_texture.c|  93 -
  src/mesa/state_tracker/st_texture.h|  34 --
  12 files changed, 580 insertions(+), 484 deletions(-)
  create mode 100644 src/mesa/state_tracker/st_sampler_view.c
  create mode 100644 src/mesa/state_tracker/st_sampler_view.h

diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index fbe5861..410a61a 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -510,6 +510,8 @@ STATETRACKER_FILES = \
 state_tracker/st_pbo.h \
 state_tracker/st_program.c \
 state_tracker/st_program.h \
+   state_tracker/st_sampler_view.c \
+   state_tracker/st_sampler_view.h \
 state_tracker/st_scissor.c \
 state_tracker/st_scissor.h \
 state_tracker/st_texture.c \
diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c
b/src/mesa/state_tracker/st_atom_pixeltransfer.c
index 26d8ade..a2951a1 100644
--- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
+++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
@@ -30,6 +30,7 @@
   */

  #include "st_context.h"
+#include "st_sampler_view.h"
  #include "st_texture.h"

  #include "util/u_inlines.h"
diff --git a/src/mesa/state_tracker/st_atom_texture.c
b/src/mesa/state_tracker/st_atom_texture.c
index e5574bd..c8ae62c 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -42,6 +42,7 @@

  #include "st_context.h"
  #include "st_atom.h"
+#include "st_sampler_view.h"
  #include "st_texture.h"
  #include "st_format.h"
  #include "st_cb_texture.h"
@@ -51,363 +52,6 @@
  #include 

Re: [Mesa-dev] [PATCH 5/5] st/mesa: move all sampler view code into new st_sampler_view.[ch] files

2016-10-03 Thread Brian Paul
Actually, I just need to bracket some of the assertions with the test 
for GL_TEXTURE_BUFFER.  I'll make that change and re-test before 
pushing.  I suspect I did my piglit run w/ a release build on Windows.


Thanks for reviewing.

-Brian

On 10/02/2016 02:53 PM, Marek Olšák wrote:

One more fix for TBOs is needed:

diff --git a/src/mesa/state_tracker/st_sampler_view.c
b/src/mesa/state_tracker/st_sampler_view.c
index da1df86..a0bea46 100644
--- a/src/mesa/state_tracker/st_sampler_view.c
+++ b/src/mesa/state_tracker/st_sampler_view.c
@@ -459,7 +459,7 @@ st_get_texture_sampler_view_from_stobj(struct
st_context *st,

 sv = st_texture_get_sampler_view(st, stObj);

-   if (*sv) {
+   if (*sv && stObj->base.Target != GL_TEXTURE_BUFFER) {
/* Debug check: make sure that the sampler view's parameters are
 * what they're supposed to be.
 */

If fixes this assertion failure:
arb_texture_buffer_range-ranges: state_tracker/st_sampler_view.c:472:
st_get_texture_sampler_view_from_stobj: Assertion `last_level(stObj)
== view->u.tex.last_level' failed.

Marek


On Sun, Oct 2, 2016 at 10:31 PM, Marek Olšák  wrote:

FYI, the series breaks this test:

piglit/bin/glsl-resource-not-bound Buffer -auto -fbo
glsl-resource-not-bound: state_tracker/st_sampler_view.c:456:
st_get_texture_sampler_view_from_stobj: Assertion `stObj->pt' failed.
Aborted

Removing the assertion fixes it. Note that empty TBO slots are NULL.

Marek



On Sun, Oct 2, 2016 at 2:29 PM, Marek Olšák  wrote:

You also need this:

diff --git a/src/mesa/state_tracker/st_vdpau.c
b/src/mesa/state_tracker/st_vdpau.c
index 4f599dd..cafbd3d 100644
--- a/src/mesa/state_tracker/st_vdpau.c
+++ b/src/mesa/state_tracker/st_vdpau.c
@@ -44,6 +44,7 @@
  #include "st_vdpau.h"
  #include "st_context.h"
  #include "st_texture.h"
+#include "st_sampler_view.h"
  #include "st_format.h"
  #include "st_cb_flush.h"

With that fixed, the series is:

Reviewed-by: Marek Olšák 

Marek



On Sat, Oct 1, 2016 at 12:53 AM, Brian Paul  wrote:

Previously, the sampler view code was scattered across several different
files.

Note, the previous REALLOC(), FREE() for st_texture_object::sampler_views
are replaced by realloc(), free() to avoid conflicting macros in Mesa vs.
Gallium.
---
  src/mesa/Makefile.sources  |   2 +
  src/mesa/state_tracker/st_atom_pixeltransfer.c |   1 +
  src/mesa/state_tracker/st_atom_texture.c   | 358 +-
  src/mesa/state_tracker/st_cb_bitmap.c  |   1 +
  src/mesa/state_tracker/st_cb_drawpixels.c  |   1 +
  src/mesa/state_tracker/st_cb_eglimage.c|   2 +
  src/mesa/state_tracker/st_cb_texture.c |   1 +
  src/mesa/state_tracker/st_context.c|   1 +
  src/mesa/state_tracker/st_sampler_view.c   | 487 +
  src/mesa/state_tracker/st_sampler_view.h   |  83 +
  src/mesa/state_tracker/st_texture.c|  93 -
  src/mesa/state_tracker/st_texture.h|  34 --
  12 files changed, 580 insertions(+), 484 deletions(-)
  create mode 100644 src/mesa/state_tracker/st_sampler_view.c
  create mode 100644 src/mesa/state_tracker/st_sampler_view.h

diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index fbe5861..410a61a 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -510,6 +510,8 @@ STATETRACKER_FILES = \
 state_tracker/st_pbo.h \
 state_tracker/st_program.c \
 state_tracker/st_program.h \
+   state_tracker/st_sampler_view.c \
+   state_tracker/st_sampler_view.h \
 state_tracker/st_scissor.c \
 state_tracker/st_scissor.h \
 state_tracker/st_texture.c \
diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c 
b/src/mesa/state_tracker/st_atom_pixeltransfer.c
index 26d8ade..a2951a1 100644
--- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
+++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
@@ -30,6 +30,7 @@
   */

  #include "st_context.h"
+#include "st_sampler_view.h"
  #include "st_texture.h"

  #include "util/u_inlines.h"
diff --git a/src/mesa/state_tracker/st_atom_texture.c 
b/src/mesa/state_tracker/st_atom_texture.c
index e5574bd..c8ae62c 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -42,6 +42,7 @@

  #include "st_context.h"
  #include "st_atom.h"
+#include "st_sampler_view.h"
  #include "st_texture.h"
  #include "st_format.h"
  #include "st_cb_texture.h"
@@ -51,363 +52,6 @@
  #include "cso_cache/cso_context.h"


-/**
- * Return swizzle1(swizzle2)
- */
-static unsigned
-swizzle_swizzle(unsigned swizzle1, unsigned swizzle2)
-{
-   unsigned i, swz[4];
-
-   if (swizzle1 == SWIZZLE_XYZW) {
-  /* identity swizzle, no change to swizzle2 */
-  return swizzle2;
-   }
-
-   for (i = 0; i < 4; i++) {
-  unsigned s = GET_SWZ(swizzle1, i);
-  switch (s) {
-  case SWIZZLE_X:
-  case 

Re: [Mesa-dev] [PATCH 5/5] st/mesa: move all sampler view code into new st_sampler_view.[ch] files

2016-10-02 Thread Marek Olšák
One more fix for TBOs is needed:

diff --git a/src/mesa/state_tracker/st_sampler_view.c
b/src/mesa/state_tracker/st_sampler_view.c
index da1df86..a0bea46 100644
--- a/src/mesa/state_tracker/st_sampler_view.c
+++ b/src/mesa/state_tracker/st_sampler_view.c
@@ -459,7 +459,7 @@ st_get_texture_sampler_view_from_stobj(struct
st_context *st,

sv = st_texture_get_sampler_view(st, stObj);

-   if (*sv) {
+   if (*sv && stObj->base.Target != GL_TEXTURE_BUFFER) {
   /* Debug check: make sure that the sampler view's parameters are
* what they're supposed to be.
*/

If fixes this assertion failure:
arb_texture_buffer_range-ranges: state_tracker/st_sampler_view.c:472:
st_get_texture_sampler_view_from_stobj: Assertion `last_level(stObj)
== view->u.tex.last_level' failed.

Marek


On Sun, Oct 2, 2016 at 10:31 PM, Marek Olšák  wrote:
> FYI, the series breaks this test:
>
> piglit/bin/glsl-resource-not-bound Buffer -auto -fbo
> glsl-resource-not-bound: state_tracker/st_sampler_view.c:456:
> st_get_texture_sampler_view_from_stobj: Assertion `stObj->pt' failed.
> Aborted
>
> Removing the assertion fixes it. Note that empty TBO slots are NULL.
>
> Marek
>
>
>
> On Sun, Oct 2, 2016 at 2:29 PM, Marek Olšák  wrote:
>> You also need this:
>>
>> diff --git a/src/mesa/state_tracker/st_vdpau.c
>> b/src/mesa/state_tracker/st_vdpau.c
>> index 4f599dd..cafbd3d 100644
>> --- a/src/mesa/state_tracker/st_vdpau.c
>> +++ b/src/mesa/state_tracker/st_vdpau.c
>> @@ -44,6 +44,7 @@
>>  #include "st_vdpau.h"
>>  #include "st_context.h"
>>  #include "st_texture.h"
>> +#include "st_sampler_view.h"
>>  #include "st_format.h"
>>  #include "st_cb_flush.h"
>>
>> With that fixed, the series is:
>>
>> Reviewed-by: Marek Olšák 
>>
>> Marek
>>
>>
>>
>> On Sat, Oct 1, 2016 at 12:53 AM, Brian Paul  wrote:
>>> Previously, the sampler view code was scattered across several different
>>> files.
>>>
>>> Note, the previous REALLOC(), FREE() for st_texture_object::sampler_views
>>> are replaced by realloc(), free() to avoid conflicting macros in Mesa vs.
>>> Gallium.
>>> ---
>>>  src/mesa/Makefile.sources  |   2 +
>>>  src/mesa/state_tracker/st_atom_pixeltransfer.c |   1 +
>>>  src/mesa/state_tracker/st_atom_texture.c   | 358 +-
>>>  src/mesa/state_tracker/st_cb_bitmap.c  |   1 +
>>>  src/mesa/state_tracker/st_cb_drawpixels.c  |   1 +
>>>  src/mesa/state_tracker/st_cb_eglimage.c|   2 +
>>>  src/mesa/state_tracker/st_cb_texture.c |   1 +
>>>  src/mesa/state_tracker/st_context.c|   1 +
>>>  src/mesa/state_tracker/st_sampler_view.c   | 487 
>>> +
>>>  src/mesa/state_tracker/st_sampler_view.h   |  83 +
>>>  src/mesa/state_tracker/st_texture.c|  93 -
>>>  src/mesa/state_tracker/st_texture.h|  34 --
>>>  12 files changed, 580 insertions(+), 484 deletions(-)
>>>  create mode 100644 src/mesa/state_tracker/st_sampler_view.c
>>>  create mode 100644 src/mesa/state_tracker/st_sampler_view.h
>>>
>>> diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
>>> index fbe5861..410a61a 100644
>>> --- a/src/mesa/Makefile.sources
>>> +++ b/src/mesa/Makefile.sources
>>> @@ -510,6 +510,8 @@ STATETRACKER_FILES = \
>>> state_tracker/st_pbo.h \
>>> state_tracker/st_program.c \
>>> state_tracker/st_program.h \
>>> +   state_tracker/st_sampler_view.c \
>>> +   state_tracker/st_sampler_view.h \
>>> state_tracker/st_scissor.c \
>>> state_tracker/st_scissor.h \
>>> state_tracker/st_texture.c \
>>> diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c 
>>> b/src/mesa/state_tracker/st_atom_pixeltransfer.c
>>> index 26d8ade..a2951a1 100644
>>> --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
>>> +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
>>> @@ -30,6 +30,7 @@
>>>   */
>>>
>>>  #include "st_context.h"
>>> +#include "st_sampler_view.h"
>>>  #include "st_texture.h"
>>>
>>>  #include "util/u_inlines.h"
>>> diff --git a/src/mesa/state_tracker/st_atom_texture.c 
>>> b/src/mesa/state_tracker/st_atom_texture.c
>>> index e5574bd..c8ae62c 100644
>>> --- a/src/mesa/state_tracker/st_atom_texture.c
>>> +++ b/src/mesa/state_tracker/st_atom_texture.c
>>> @@ -42,6 +42,7 @@
>>>
>>>  #include "st_context.h"
>>>  #include "st_atom.h"
>>> +#include "st_sampler_view.h"
>>>  #include "st_texture.h"
>>>  #include "st_format.h"
>>>  #include "st_cb_texture.h"
>>> @@ -51,363 +52,6 @@
>>>  #include "cso_cache/cso_context.h"
>>>
>>>
>>> -/**
>>> - * Return swizzle1(swizzle2)
>>> - */
>>> -static unsigned
>>> -swizzle_swizzle(unsigned swizzle1, unsigned swizzle2)
>>> -{
>>> -   unsigned i, swz[4];
>>> -
>>> -   if (swizzle1 == SWIZZLE_XYZW) {
>>> -  /* identity swizzle, no change to swizzle2 */
>>> -  return swizzle2;
>>> -   }
>>> -
>>> -   for (i = 0; i < 4; i++) {
>>> -  unsigned s = 

Re: [Mesa-dev] [PATCH 5/5] st/mesa: move all sampler view code into new st_sampler_view.[ch] files

2016-10-02 Thread Marek Olšák
FYI, the series breaks this test:

piglit/bin/glsl-resource-not-bound Buffer -auto -fbo
glsl-resource-not-bound: state_tracker/st_sampler_view.c:456:
st_get_texture_sampler_view_from_stobj: Assertion `stObj->pt' failed.
Aborted

Removing the assertion fixes it. Note that empty TBO slots are NULL.

Marek



On Sun, Oct 2, 2016 at 2:29 PM, Marek Olšák  wrote:
> You also need this:
>
> diff --git a/src/mesa/state_tracker/st_vdpau.c
> b/src/mesa/state_tracker/st_vdpau.c
> index 4f599dd..cafbd3d 100644
> --- a/src/mesa/state_tracker/st_vdpau.c
> +++ b/src/mesa/state_tracker/st_vdpau.c
> @@ -44,6 +44,7 @@
>  #include "st_vdpau.h"
>  #include "st_context.h"
>  #include "st_texture.h"
> +#include "st_sampler_view.h"
>  #include "st_format.h"
>  #include "st_cb_flush.h"
>
> With that fixed, the series is:
>
> Reviewed-by: Marek Olšák 
>
> Marek
>
>
>
> On Sat, Oct 1, 2016 at 12:53 AM, Brian Paul  wrote:
>> Previously, the sampler view code was scattered across several different
>> files.
>>
>> Note, the previous REALLOC(), FREE() for st_texture_object::sampler_views
>> are replaced by realloc(), free() to avoid conflicting macros in Mesa vs.
>> Gallium.
>> ---
>>  src/mesa/Makefile.sources  |   2 +
>>  src/mesa/state_tracker/st_atom_pixeltransfer.c |   1 +
>>  src/mesa/state_tracker/st_atom_texture.c   | 358 +-
>>  src/mesa/state_tracker/st_cb_bitmap.c  |   1 +
>>  src/mesa/state_tracker/st_cb_drawpixels.c  |   1 +
>>  src/mesa/state_tracker/st_cb_eglimage.c|   2 +
>>  src/mesa/state_tracker/st_cb_texture.c |   1 +
>>  src/mesa/state_tracker/st_context.c|   1 +
>>  src/mesa/state_tracker/st_sampler_view.c   | 487 
>> +
>>  src/mesa/state_tracker/st_sampler_view.h   |  83 +
>>  src/mesa/state_tracker/st_texture.c|  93 -
>>  src/mesa/state_tracker/st_texture.h|  34 --
>>  12 files changed, 580 insertions(+), 484 deletions(-)
>>  create mode 100644 src/mesa/state_tracker/st_sampler_view.c
>>  create mode 100644 src/mesa/state_tracker/st_sampler_view.h
>>
>> diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
>> index fbe5861..410a61a 100644
>> --- a/src/mesa/Makefile.sources
>> +++ b/src/mesa/Makefile.sources
>> @@ -510,6 +510,8 @@ STATETRACKER_FILES = \
>> state_tracker/st_pbo.h \
>> state_tracker/st_program.c \
>> state_tracker/st_program.h \
>> +   state_tracker/st_sampler_view.c \
>> +   state_tracker/st_sampler_view.h \
>> state_tracker/st_scissor.c \
>> state_tracker/st_scissor.h \
>> state_tracker/st_texture.c \
>> diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c 
>> b/src/mesa/state_tracker/st_atom_pixeltransfer.c
>> index 26d8ade..a2951a1 100644
>> --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
>> +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
>> @@ -30,6 +30,7 @@
>>   */
>>
>>  #include "st_context.h"
>> +#include "st_sampler_view.h"
>>  #include "st_texture.h"
>>
>>  #include "util/u_inlines.h"
>> diff --git a/src/mesa/state_tracker/st_atom_texture.c 
>> b/src/mesa/state_tracker/st_atom_texture.c
>> index e5574bd..c8ae62c 100644
>> --- a/src/mesa/state_tracker/st_atom_texture.c
>> +++ b/src/mesa/state_tracker/st_atom_texture.c
>> @@ -42,6 +42,7 @@
>>
>>  #include "st_context.h"
>>  #include "st_atom.h"
>> +#include "st_sampler_view.h"
>>  #include "st_texture.h"
>>  #include "st_format.h"
>>  #include "st_cb_texture.h"
>> @@ -51,363 +52,6 @@
>>  #include "cso_cache/cso_context.h"
>>
>>
>> -/**
>> - * Return swizzle1(swizzle2)
>> - */
>> -static unsigned
>> -swizzle_swizzle(unsigned swizzle1, unsigned swizzle2)
>> -{
>> -   unsigned i, swz[4];
>> -
>> -   if (swizzle1 == SWIZZLE_XYZW) {
>> -  /* identity swizzle, no change to swizzle2 */
>> -  return swizzle2;
>> -   }
>> -
>> -   for (i = 0; i < 4; i++) {
>> -  unsigned s = GET_SWZ(swizzle1, i);
>> -  switch (s) {
>> -  case SWIZZLE_X:
>> -  case SWIZZLE_Y:
>> -  case SWIZZLE_Z:
>> -  case SWIZZLE_W:
>> - swz[i] = GET_SWZ(swizzle2, s);
>> - break;
>> -  case SWIZZLE_ZERO:
>> - swz[i] = SWIZZLE_ZERO;
>> - break;
>> -  case SWIZZLE_ONE:
>> - swz[i] = SWIZZLE_ONE;
>> - break;
>> -  default:
>> - assert(!"Bad swizzle term");
>> - swz[i] = SWIZZLE_X;
>> -  }
>> -   }
>> -
>> -   return MAKE_SWIZZLE4(swz[0], swz[1], swz[2], swz[3]);
>> -}
>> -
>> -
>> -/**
>> - * Given a user-specified texture base format, the actual gallium texture
>> - * format and the current GL_DEPTH_MODE, return a texture swizzle.
>> - *
>> - * Consider the case where the user requests a GL_RGB internal texture
>> - * format the driver actually uses an RGBA format.  The A component should
>> - * be ignored and sampling from the texture should always return (r,g,b,1).
>> - * But if we 

Re: [Mesa-dev] [PATCH 5/5] st/mesa: move all sampler view code into new st_sampler_view.[ch] files

2016-10-02 Thread Marek Olšák
You also need this:

diff --git a/src/mesa/state_tracker/st_vdpau.c
b/src/mesa/state_tracker/st_vdpau.c
index 4f599dd..cafbd3d 100644
--- a/src/mesa/state_tracker/st_vdpau.c
+++ b/src/mesa/state_tracker/st_vdpau.c
@@ -44,6 +44,7 @@
 #include "st_vdpau.h"
 #include "st_context.h"
 #include "st_texture.h"
+#include "st_sampler_view.h"
 #include "st_format.h"
 #include "st_cb_flush.h"

With that fixed, the series is:

Reviewed-by: Marek Olšák 

Marek



On Sat, Oct 1, 2016 at 12:53 AM, Brian Paul  wrote:
> Previously, the sampler view code was scattered across several different
> files.
>
> Note, the previous REALLOC(), FREE() for st_texture_object::sampler_views
> are replaced by realloc(), free() to avoid conflicting macros in Mesa vs.
> Gallium.
> ---
>  src/mesa/Makefile.sources  |   2 +
>  src/mesa/state_tracker/st_atom_pixeltransfer.c |   1 +
>  src/mesa/state_tracker/st_atom_texture.c   | 358 +-
>  src/mesa/state_tracker/st_cb_bitmap.c  |   1 +
>  src/mesa/state_tracker/st_cb_drawpixels.c  |   1 +
>  src/mesa/state_tracker/st_cb_eglimage.c|   2 +
>  src/mesa/state_tracker/st_cb_texture.c |   1 +
>  src/mesa/state_tracker/st_context.c|   1 +
>  src/mesa/state_tracker/st_sampler_view.c   | 487 
> +
>  src/mesa/state_tracker/st_sampler_view.h   |  83 +
>  src/mesa/state_tracker/st_texture.c|  93 -
>  src/mesa/state_tracker/st_texture.h|  34 --
>  12 files changed, 580 insertions(+), 484 deletions(-)
>  create mode 100644 src/mesa/state_tracker/st_sampler_view.c
>  create mode 100644 src/mesa/state_tracker/st_sampler_view.h
>
> diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
> index fbe5861..410a61a 100644
> --- a/src/mesa/Makefile.sources
> +++ b/src/mesa/Makefile.sources
> @@ -510,6 +510,8 @@ STATETRACKER_FILES = \
> state_tracker/st_pbo.h \
> state_tracker/st_program.c \
> state_tracker/st_program.h \
> +   state_tracker/st_sampler_view.c \
> +   state_tracker/st_sampler_view.h \
> state_tracker/st_scissor.c \
> state_tracker/st_scissor.h \
> state_tracker/st_texture.c \
> diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c 
> b/src/mesa/state_tracker/st_atom_pixeltransfer.c
> index 26d8ade..a2951a1 100644
> --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
> +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
> @@ -30,6 +30,7 @@
>   */
>
>  #include "st_context.h"
> +#include "st_sampler_view.h"
>  #include "st_texture.h"
>
>  #include "util/u_inlines.h"
> diff --git a/src/mesa/state_tracker/st_atom_texture.c 
> b/src/mesa/state_tracker/st_atom_texture.c
> index e5574bd..c8ae62c 100644
> --- a/src/mesa/state_tracker/st_atom_texture.c
> +++ b/src/mesa/state_tracker/st_atom_texture.c
> @@ -42,6 +42,7 @@
>
>  #include "st_context.h"
>  #include "st_atom.h"
> +#include "st_sampler_view.h"
>  #include "st_texture.h"
>  #include "st_format.h"
>  #include "st_cb_texture.h"
> @@ -51,363 +52,6 @@
>  #include "cso_cache/cso_context.h"
>
>
> -/**
> - * Return swizzle1(swizzle2)
> - */
> -static unsigned
> -swizzle_swizzle(unsigned swizzle1, unsigned swizzle2)
> -{
> -   unsigned i, swz[4];
> -
> -   if (swizzle1 == SWIZZLE_XYZW) {
> -  /* identity swizzle, no change to swizzle2 */
> -  return swizzle2;
> -   }
> -
> -   for (i = 0; i < 4; i++) {
> -  unsigned s = GET_SWZ(swizzle1, i);
> -  switch (s) {
> -  case SWIZZLE_X:
> -  case SWIZZLE_Y:
> -  case SWIZZLE_Z:
> -  case SWIZZLE_W:
> - swz[i] = GET_SWZ(swizzle2, s);
> - break;
> -  case SWIZZLE_ZERO:
> - swz[i] = SWIZZLE_ZERO;
> - break;
> -  case SWIZZLE_ONE:
> - swz[i] = SWIZZLE_ONE;
> - break;
> -  default:
> - assert(!"Bad swizzle term");
> - swz[i] = SWIZZLE_X;
> -  }
> -   }
> -
> -   return MAKE_SWIZZLE4(swz[0], swz[1], swz[2], swz[3]);
> -}
> -
> -
> -/**
> - * Given a user-specified texture base format, the actual gallium texture
> - * format and the current GL_DEPTH_MODE, return a texture swizzle.
> - *
> - * Consider the case where the user requests a GL_RGB internal texture
> - * format the driver actually uses an RGBA format.  The A component should
> - * be ignored and sampling from the texture should always return (r,g,b,1).
> - * But if we rendered to the texture we might have written A values != 1.
> - * By sampling the texture with a ".xyz1" swizzle we'll get the expected A=1.
> - * This function computes the texture swizzle needed to get the expected
> - * values.
> - *
> - * In the case of depth textures, the GL_DEPTH_MODE state determines the
> - * texture swizzle.
> - *
> - * This result must be composed with the user-specified swizzle to get
> - * the final swizzle.
> - */
> -static unsigned
> -compute_texture_format_swizzle(GLenum baseFormat, GLenum depthMode,