[Mesa-dev] [PATCH] softpipe: remove the 32bits limitation on depth(-stencil) formats

2011-12-07 Thread Morgan Armand
This patch remove the 32bits limitation. As a side effect, it bring the support 
for the GL_ARB_depth_buffer_float extension.
No regression have been found on piglit, and all tests for 
GL_ARB_depth_buffer_float pass successfully.

---
 src/gallium/auxiliary/util/u_tile.c   |   28 +
 src/gallium/drivers/softpipe/sp_clear.c   |4 +-
 src/gallium/drivers/softpipe/sp_quad_depth_test.c |   44 -
 src/gallium/drivers/softpipe/sp_screen.c  |   13 --
 src/gallium/drivers/softpipe/sp_tile_cache.c  |   18 +++-
 src/gallium/drivers/softpipe/sp_tile_cache.h  |5 +-
 6 files changed, 91 insertions(+), 21 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_tile.c 
b/src/gallium/auxiliary/util/u_tile.c
index 02bdb73..357e896 100644
--- a/src/gallium/auxiliary/util/u_tile.c
+++ b/src/gallium/auxiliary/util/u_tile.c
@@ -344,6 +344,31 @@ z32f_x24s8_get_tile_rgba(const float *src,
}
 }

+/*** PIPE_FORMAT_X32_S8X24_UINT ***/
+
+/**
+ * Return S component as four uint32_t in [0..255].  Z part ignored.
+ */
+static void
+x32_s8_get_tile_rgba(const unsigned *src,
+ unsigned w, unsigned h,
+ float *p,
+ unsigned dst_stride)
+{
+   unsigned i, j;
+
+   for (i = 0; i < h; i++) {
+  float *pRow = p;
+  for (j = 0; j < w; j++, pRow += 4) {
+ src++;
+ pRow[0] =
+ pRow[1] =
+ pRow[2] =
+ pRow[3] = (float)(*src++ & 0xff);
+  }
+  p += dst_stride;
+   }
+}

 void
 pipe_tile_raw_to_rgba(enum pipe_format format,
@@ -381,6 +406,9 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
   z32f_x24s8_get_tile_rgba((float *) src, w, h, dst, dst_stride);
   break;
+   case PIPE_FORMAT_X32_S8X24_UINT:
+  x32_s8_get_tile_rgba((float *) src, w, h, dst, dst_stride);
+  break;
default:
   util_format_read_4f(format,
   dst, dst_stride * sizeof(float),
diff --git a/src/gallium/drivers/softpipe/sp_clear.c 
b/src/gallium/drivers/softpipe/sp_clear.c
index b59524a..dd6bd83 100644
--- a/src/gallium/drivers/softpipe/sp_clear.c
+++ b/src/gallium/drivers/softpipe/sp_clear.c
@@ -50,7 +50,7 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers,
double depth, unsigned stencil)
 {
struct softpipe_context *softpipe = softpipe_context(pipe);
-   unsigned cv;
+   uint64_t cv;
uint i;

if (softpipe->no_rast)
@@ -73,7 +73,7 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers,
   static const union pipe_color_union zero;
   struct pipe_surface *ps = softpipe->framebuffer.zsbuf;

-  cv = util_pack_z_stencil(ps->format, depth, stencil);
+  cv = util_pack64_z_stencil(ps->format, depth, stencil);
   sp_tile_cache_clear(softpipe->zsbuf_cache, &zero, cv);
}

diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c 
b/src/gallium/drivers/softpipe/sp_quad_depth_test.c
index 4cf378e..529a5ad 100644
--- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c
+++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c
@@ -32,6 +32,7 @@

 #include "pipe/p_defines.h"
 #include "util/u_format.h"
+#include "util/u_math.h"
 #include "util/u_memory.h"
 #include "tgsi/tgsi_scan.h"
 #include "sp_context.h"
@@ -102,6 +103,21 @@ get_depth_stencil_values( struct depth_data *data,
  data->stencilVals[j] = tile->data.stencil8[y][x];
   }
   break;
+   case PIPE_FORMAT_Z32_FLOAT:
+  for (j = 0; j < QUAD_SIZE; j++) {
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
+ data->b[j] = tile->data.depth32[y][x];
+  }
+  break;
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
+  for (j = 0; j < QUAD_SIZE; j++) {
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
+ data->b[j] = tile->data.depth64[y][x] & 0x;
+ data->stencilVals[j] = (tile->data.depth64[y][x] >> 32) & 0xff;
+  }
+  break;
default:
   assert(0);
}
@@ -182,6 +198,17 @@ convert_quad_depth( struct depth_data *data,
  }
   }
   break;
+   case PIPE_FORMAT_Z32_FLOAT:
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
+  {
+ union fi fui;
+
+ for (j = 0; j < QUAD_SIZE; j++) {
+fui.f = quad->output.depth[j];
+data->q[j] = fui.ui;
+ }
+  }
+  break;
default:
   assert(0);
}
@@ -207,6 +234,8 @@ convert_quad_stencil( struct depth_data *data,
case PIPE_FORMAT_X8Z24_UNORM:
case PIPE_FORMAT_S8_UINT_Z24_UNORM:
case PIPE_FORMAT_S8_UINT:
+   case PIPE_FORMAT_Z32_FLOAT:
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
   for (j = 0; j < QUAD_SIZE; j++) {
  data->shader_stencil_refs[j] = ((unsigned)(quad->output.stencil[j]));
   }
@@ -272,7 +301,20 @@ write_depth_stencil_values( struct depth

[Mesa-dev] [PATCH] glsl: fix structure splitting for ir_texture

2012-01-21 Thread Morgan Armand
This patch fix an assertion in in-parameter-struct and normal-parameter-struct.

However, both tests still fail because _mesa_get_sampler_uniform_value handles 
global uniform
samplers only.

Looking at the specification, it's not really clear that sampler*D are valid as 
a structure member.

>From GLSL Specification 1.10, Section 4.1.7:
Samplers can only be declared as function parameters or uniforms (see Section 
4.3.5 “Uniform”).
Samplers are not allowed to be operands in expressions nor can they be assigned 
into.

On nvidia hardware, it seems to be supported. I would appreciate to know what 
other people think,
and what's the status of other hardware vendors since I don't have any 
ati/intel hardware here.

---
 src/glsl/opt_structure_splitting.cpp |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/glsl/opt_structure_splitting.cpp 
b/src/glsl/opt_structure_splitting.cpp
index 2c1f6bb..8b1f1b3 100644
--- a/src/glsl/opt_structure_splitting.cpp
+++ b/src/glsl/opt_structure_splitting.cpp
@@ -189,6 +189,7 @@ public:
{
}

+   virtual ir_visitor_status visit_leave(ir_texture *);
virtual ir_visitor_status visit_leave(ir_assignment *);

void split_deref(ir_dereference **deref);
@@ -259,6 +260,14 @@ ir_structure_splitting_visitor::handle_rvalue(ir_rvalue 
**rvalue)
 }

 ir_visitor_status
+ir_structure_splitting_visitor::visit_leave(ir_texture *ir)
+{
+   split_deref(&ir->sampler);
+
+   return ir_rvalue_visitor::visit_leave(ir);
+}
+
+ir_visitor_status
 ir_structure_splitting_visitor::visit_leave(ir_assignment *ir)
 {
ir_dereference_variable *lhs_deref = ir->lhs->as_dereference_variable();
-- 
1.7.7.1.msysgit.0

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


Re: [Mesa-dev] [PATCH] gallium: implement WGL_ARB_create_context

2011-10-25 Thread morgan armand
Here is the modified patch. I just checked if it works but doesn't
have a good test case for it. But I will write one for sure!

---
 src/gallium/state_trackers/wgl/SConscript  |1 +
 src/gallium/state_trackers/wgl/stw_context.c   |   47 +++-
 src/gallium/state_trackers/wgl/stw_context.h   |3 +
 src/gallium/state_trackers/wgl/stw_ext_context.c   |  119 
 .../state_trackers/wgl/stw_getprocaddress.c|3 +
 5 files changed, 166 insertions(+), 7 deletions(-)
 create mode 100644 src/gallium/state_trackers/wgl/stw_ext_context.c

diff --git a/src/gallium/state_trackers/wgl/SConscript
b/src/gallium/state_trackers/wgl/SConscript
index 7cb953b..1014b45 100644
--- a/src/gallium/state_trackers/wgl/SConscript
+++ b/src/gallium/state_trackers/wgl/SConscript
@@ -22,6 +22,7 @@ if not env['gles']:
 sources = [
 'stw_context.c',
 'stw_device.c',
+'stw_ext_context.c',
 'stw_ext_extensionsstring.c',
 'stw_ext_gallium.c',
 'stw_ext_pbuffer.c',
diff --git a/src/gallium/state_trackers/wgl/stw_context.c
b/src/gallium/state_trackers/wgl/stw_context.c
index c2839fe..6cc8a83 100644
--- a/src/gallium/state_trackers/wgl/stw_context.c
+++ b/src/gallium/state_trackers/wgl/stw_context.c
@@ -27,6 +27,11 @@

 #include 

+#define WGL_WGLEXT_PROTOTYPES
+
+#include 
+#include 
+
 #include "pipe/p_compiler.h"
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
@@ -121,23 +126,41 @@ DrvCreateLayerContext(
HDC hdc,
INT iLayerPlane )
 {
+   return stw_create_context_attribs(hdc, iLayerPlane, 0, 1, 0, 0,
WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB);
+}
+
+DHGLRC
+stw_create_context_attribs(
+   HDC hdc,
+   INT iLayerPlane,
+   DHGLRC hShareContext,
+   int majorVersion, int minorVersion,
+   int contextFlags, int profileMask)
+{
int iPixelFormat;
const struct stw_pixelformat_info *pfi;
struct st_context_attribs attribs;
struct stw_context *ctx = NULL;
-
-   if(!stw_dev)
+   struct stw_context *shareCtx = NULL;
+
+   if (!stw_dev)
   return 0;
-
+
if (iLayerPlane != 0)
   return 0;

iPixelFormat = GetPixelFormat(hdc);
if(!iPixelFormat)
   return 0;
-
+
pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
-
+
+   if (hShareContext != 0) {
+  pipe_mutex_lock( stw_dev->ctx_mutex );
+  shareCtx = stw_lookup_context_locked( hShareContext );
+  pipe_mutex_unlock( stw_dev->ctx_mutex );
+   }
+
ctx = CALLOC_STRUCT( stw_context );
if (ctx == NULL)
   goto no_ctx;
@@ -148,10 +171,20 @@ DrvCreateLayerContext(
memset(&attribs, 0, sizeof(attribs));
attribs.profile = ST_PROFILE_DEFAULT;
attribs.visual = pfi->stvis;
+   attribs.major = majorVersion;
+   attribs.minor = minorVersion;
+   if (contextFlags & WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB)
+  attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
+   if (contextFlags & WGL_CONTEXT_DEBUG_BIT_ARB)
+  attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
+   if (profileMask & WGL_CONTEXT_CORE_PROFILE_BIT_ARB)
+  attribs.flags |= ST_CONTEXT_FLAG_CORE_PROFILE;
+   if (profileMask & WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB)
+  attribs.flags |= ST_CONTEXT_FLAG_COMPATIBLE_PROFILE;

ctx->st = stw_dev->stapi->create_context(stw_dev->stapi,
- stw_dev->smapi, &attribs, NULL);
-   if (ctx->st == NULL)
+ stw_dev->smapi, &attribs, shareCtx ? shareCtx->st : NULL);
+   if (ctx->st == NULL)
   goto no_st_ctx;

ctx->st->st_manager_private = (void *) ctx;
diff --git a/src/gallium/state_trackers/wgl/stw_context.h
b/src/gallium/state_trackers/wgl/stw_context.h
index 0bbed84..07a5c7d 100644
--- a/src/gallium/state_trackers/wgl/stw_context.h
+++ b/src/gallium/state_trackers/wgl/stw_context.h
@@ -43,6 +43,9 @@ struct stw_context
struct stw_framebuffer *current_framebuffer;
 };

+DHGLRC stw_create_context_attribs( HDC hdc, INT iLayerPlane, DHGLRC
hShareContext,
+   int majorVersion, int
minorVersion, int contextFlags, int profileMask );
+
 DHGLRC stw_get_current_context( void );

 HDC stw_get_current_dc( void );
diff --git a/src/gallium/state_trackers/wgl/stw_ext_context.c
b/src/gallium/state_trackers/wgl/stw_ext_context.c
new file mode 100644
index 000..a3470ac
--- /dev/null
+++ b/src/gallium/state_trackers/wgl/stw_ext_context.c
@@ -0,0 +1,119 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.11
+ *
+ * Copyright (C) 2011 Morgan Armand 
+ *
+ * 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 

Re: [Mesa-dev] [PATCH] gallium: implement WGL_ARB_create_context

2011-10-28 Thread morgan armand
ckers/wgl/stw_context.h
>> b/src/gallium/state_trackers/wgl/stw_context.h
>> index 0bbed84..07a5c7d 100644
>> --- a/src/gallium/state_trackers/wgl/stw_context.h
>> +++ b/src/gallium/state_trackers/wgl/stw_context.h
>> @@ -43,6 +43,9 @@ struct stw_context
>>     struct stw_framebuffer *current_framebuffer;
>>  };
>>
>> +DHGLRC stw_create_context_attribs( HDC hdc, INT iLayerPlane, DHGLRC
>> hShareContext,
>> +                                   int majorVersion, int
>> minorVersion, int contextFlags, int profileMask );
>> +
>>  DHGLRC stw_get_current_context( void );
>>
>>  HDC stw_get_current_dc( void );
>> diff --git a/src/gallium/state_trackers/wgl/stw_ext_context.c
>> b/src/gallium/state_trackers/wgl/stw_ext_context.c
>> new file mode 100644
>> index 000..a3470ac
>> --- /dev/null
>> +++ b/src/gallium/state_trackers/wgl/stw_ext_context.c
>> @@ -0,0 +1,119 @@
>> +/*
>> + * Mesa 3-D graphics library
>> + * Version:  7.11
>> + *
>> + * Copyright (C) 2011 Morgan Armand 
>> + *
>> + * 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 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
>> + * BRIAN PAUL 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 
>> +
>> +#define WGL_WGLEXT_PROTOTYPES
>> +
>> +#include 
>> +#include 
>> +
>> +#include "stw_icd.h"
>> +#include "stw_context.h"
>> +
>> +HGLRC WINAPI
>> +wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, const int
>> *attribList)
>> +{
>> +   int majorVersion = 1, minorVersion = 0, layerPlane = 0;
>> +   int contextFlags = 0x0;
>> +   int profileMask = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
>> +   int i;
>> +   BOOL done = FALSE;
>> +
>> +   /* parse attrib_list */
>> +   if (attribList) {
>> +      for (i = 0; !done && attribList[i]; i++) {
>> +         switch (attribList[i]) {
>> +         case WGL_CONTEXT_MAJOR_VERSION_ARB:
>> +            majorVersion = attribList[++i];
>> +            break;
>> +         case WGL_CONTEXT_MINOR_VERSION_ARB:
>> +            minorVersion = attribList[++i];
>> +            break;
>> +         case WGL_CONTEXT_LAYER_PLANE_ARB:
>> +            layerPlane = attribList[++i];
>> +            break;
>> +         case WGL_CONTEXT_FLAGS_ARB:
>> +            contextFlags = attribList[++i];
>> +            break;
>> +         case WGL_CONTEXT_PROFILE_MASK_ARB:
>> +            profileMask = attribList[++i];
>> +            break;
>> +         case 0:
>> +            /* end of list */
>> +            done = TRUE;
>> +            break;
>> +         default:
>> +            /* bad attribute */
>> +            SetLastError(ERROR_INVALID_PARAMETER);
>> +            return NULL;
>> +         }
>> +      }
>> +   }
>> +
>> +   /* check version (generate ERROR_INVALID_VERSION_ARB if bad) */
>> +   switch (majorVersion) {
>> +   case 1:
>> +      if (minorVersion < 0 || minorVersion > 5) {
>> +         SetLastError(ERROR_INVALID_VERSION_ARB);
>> +         return NULL;
>> +      }
>> +      break;
>> +   case 2:
>> +      if (minorVersion < 0 || minorVersion > 1) {
>> +         SetLastError(ERROR_INVALID_VERSION_ARB);
>> +         return NULL;
>> +      }
>> +      break;
>> +   case 3:
>> +      if (minorVersion < 0 || minorVersion > 3) {
>> 

[Mesa-dev] [PATCH] fix compilation of glsl_lexer.ll with msvc

2011-10-29 Thread Morgan Armand
strtoull is not supported on msvc (as there is no C99 support).

---
 src/glsl/glsl_lexer.ll |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index e444536..00065d5 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -93,7 +93,11 @@ literal_integer(char *text, int len, struct
_mesa_glsl_parse_state *state,
if (base == 16)
   digits += 2;

+#ifdef _MSC_VER
+   __int64 value = _strtoui64(digits, NULL, base);
+#else
unsigned long long value = strtoull(digits, NULL, base);
+#endif

lval->n = (int)value;

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


Re: [Mesa-dev] [PATCH] fix compilation of glsl_lexer.ll with msvc

2011-10-29 Thread Morgan Armand
On 10/29/2011 11:50 AM, Kenneth Graunke wrote:
> On 10/29/2011 01:42 AM, Morgan Armand wrote:
>> strtoull is not supported on msvc (as there is no C99 support).
>>
>> ---
>>  src/glsl/glsl_lexer.ll |4 
>>  1 files changed, 4 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
>> index e444536..00065d5 100644
>> --- a/src/glsl/glsl_lexer.ll
>> +++ b/src/glsl/glsl_lexer.ll
>> @@ -93,7 +93,11 @@ literal_integer(char *text, int len, struct
>> _mesa_glsl_parse_state *state,
>> if (base == 16)
>>digits += 2;
>>  
>> +#ifdef _MSC_VER
>> +   __int64 value = _strtoui64(digits, NULL, base);
>
> Presumably this should be "unsigned __int64" to match the code below?
Yes, you're right.
>
>> +#else
>> unsigned long long value = strtoull(digits, NULL, base);
>> +#endif
>>  
>> lval->n = (int)value;
>
> I kind of wish we just had c99.c/c99.h files with #ifdef MSVC guards
> that defined the necessary missing C99 functions, with their normal
> names and arguments, in terms of their MSVC equivalent.  Then we
> wouldn't need to litter the code with workarounds.
>
> Though, that's something for a later time.
Sounds like a good idea too! Here is the corrected (and hopefully not
wrapped) patch.

---
 src/glsl/glsl_lexer.ll |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index e444536..5364841 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -93,7 +93,11 @@ literal_integer(char *text, int len, struct
_mesa_glsl_parse_state *state,
if (base == 16)
   digits += 2;
 
+#ifdef _MSC_VER
+   unsigned __int64 value = _strtoui64(digits, NULL, base);
+#else
unsigned long long value = strtoull(digits, NULL, base);
+#endif
 
lval->n = (int)value;
 
-- 
1.7.7.1.msysgit.0

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


[Mesa-dev] [PATCH] Mesa-demos: add wglcontext to test the creation of a context through WGL_ARB_create_context

2011-10-30 Thread Morgan Armand
---
 src/wgl/CMakeLists.txt |1 +
 src/wgl/wglcontext.c   |  274

 2 files changed, 275 insertions(+), 0 deletions(-)
 create mode 100644 src/wgl/wglcontext.c

diff --git a/src/wgl/CMakeLists.txt b/src/wgl/CMakeLists.txt
index 834e836..88e6a20 100644
--- a/src/wgl/CMakeLists.txt
+++ b/src/wgl/CMakeLists.txt
@@ -13,5 +13,6 @@ add_executable (wgl_sharedtex_mt sharedtex_mt.c)
 set_target_properties (wgl_sharedtex_mt PROPERTIES OUTPUT_NAME
sharedtex_mt)
 
 add_executable (wglinfo wglinfo.c)
+add_executable (wglcontext wglcontext.c)
 
 install (TARGETS wglthreads wgl_sharedtex_mt wglinfo DESTINATION wgl)
diff --git a/src/wgl/wglcontext.c b/src/wgl/wglcontext.c
new file mode 100644
index 000..41e44cd
--- /dev/null
+++ b/src/wgl/wglcontext.c
@@ -0,0 +1,274 @@
+/*
+ * Copyright (C) 2011 Morgan Armand 
+ *
+ * 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 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 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static LRESULT CALLBACK
+WndProc(HWND hWnd,
+UINT uMsg,
+WPARAM wParam,
+LPARAM lParam )
+{
+   switch (uMsg) {
+   case WM_DESTROY:
+  PostQuitMessage(0);
+  break;
+   default:
+  return DefWindowProc(hWnd, uMsg, wParam, lParam);
+   }
+
+   return 0;
+}
+
+static char *
+context_error_to_string(DWORD error)
+{
+   switch (error) {
+   case ERROR_INVALID_VERSION_ARB:  return "ERROR_INVALID_VERSION_ARB";
+   case ERROR_INVALID_PROFILE_ARB:  return "ERROR_INVALID_PROFILE_ARB";
+   case ERROR_INVALID_OPERATION:return "ERROR_INVALID_OPERATION";
+   case ERROR_DC_NOT_FOUND: return "ERROR_DC_NOT_FOUND";
+   case ERROR_INVALID_PIXEL_FORMAT: return "ERROR_INVALID_PIXEL_FORMAT";
+   case ERROR_NO_SYSTEM_RESOURCES:  return "ERROR_NO_SYSTEM_RESOURCES";
+   case ERROR_INVALID_PARAMETER:return "ERROR_INVALID_PARAMETER";
+   default: return "Unknown Error";
+   }
+}
+
+static char *
+profile_mask_to_string(GLint profileMask)
+{
+   switch (profileMask) {
+   case WGL_CONTEXT_CORE_PROFILE_BIT_ARB:
+  return "WGL_CONTEXT_CORE_PROFILE_BIT_ARB";
+   case WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB:
+  return "WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB";
+   default:
+  return "0";
+   }
+}
+
+static void
+print_context_infos()
+{
+   GLint majorVersion;
+   GLint minorVersion;
+   GLint profileMask;
+   const GLubyte *version;
+
+   fprintf(stdout, "Context Informations\n");
+
+   version = glGetString(GL_VERSION);
+   fprintf(stdout, "GL_VERSION: %s\n", glGetString(GL_VERSION));
+
+   // Request informations with the new 3.x features.
+   if (sscanf(version, "%d.%d", &majorVersion, &minorVersion) != 2)
+  return;
+
+   if (majorVersion >= 3) {
+  glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
+  glGetIntegerv(GL_MINOR_VERSION, &minorVersion);
+  glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profileMask);
+  fprintf(stdout, "GL_MAJOR_VERSION: %d\n", majorVersion);
+  fprintf(stdout, "GL_MINOR_VERSION: %d\n", minorVersion);
+  fprintf(stdout, "GL_CONTEXT_PROFILE_MASK: %s\n",
profile_mask_to_string(profileMask));
+   }
+}
+
+static void
+create_context(int majorVersion, int minorVersion, int profileMask, int
contextFlags)
+{
+   WNDCLASS wc;
+   HWND win;
+   HDC hdc;
+   PIXELFORMATDESCRIPTOR pfd;
+   int pixelFormat;
+   HGLRC tmp, ctx;
+   PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
+   int attribsList[] = {
+  WGL_CONTEXT_MAJOR_VERSION_ARB, 1,
+  WGL_CONTEXT_MINOR_VERSION_ARB, 0,
+  WGL_CONTEXT_FLAGS_ARB, 0,
+  WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
+  0
+   };
+
+   memset(&wc, 0, sizeof(wc));
+   wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
+   wc.lpfnWndProc = WndP

Re: [Mesa-dev] [PATCH] Mesa-demos: add wglcontext to test the creation of a context through WGL_ARB_create_context

2011-11-02 Thread Morgan Armand
I got this error too on nvidia when requesting a context with a version <=
3.2, but from what I understand from the spec, this is not the correct
behavior.
The 0x2096 part corresponds to ERROR_INVALID_PROFILE_ARB (I don't know what
is the meaning of the 0xc007 part and if it is nvidia specific or not).

I would be very interested to know what is the behavior of others vendors
but I only have nvidia hardware here.

On Wed, Nov 2, 2011 at 1:17 PM, Jose Fonseca  wrote:

> I've pushed, but it doesn't work on nvidia.
>
> It fails with error 0xc0072096.
>
> Have you tried with different implementations?
>
> Jose
>
> - Original Message -
> > ---
> >  src/wgl/CMakeLists.txt |1 +
> >  src/wgl/wglcontext.c   |  274
> > 
> >  2 files changed, 275 insertions(+), 0 deletions(-)
> >  create mode 100644 src/wgl/wglcontext.c
> >
> > diff --git a/src/wgl/CMakeLists.txt b/src/wgl/CMakeLists.txt
> > index 834e836..88e6a20 100644
> > --- a/src/wgl/CMakeLists.txt
> > +++ b/src/wgl/CMakeLists.txt
> > @@ -13,5 +13,6 @@ add_executable (wgl_sharedtex_mt sharedtex_mt.c)
> >  set_target_properties (wgl_sharedtex_mt PROPERTIES OUTPUT_NAME
> > sharedtex_mt)
> >
> >  add_executable (wglinfo wglinfo.c)
> > +add_executable (wglcontext wglcontext.c)
> >
> >  install (TARGETS wglthreads wgl_sharedtex_mt wglinfo DESTINATION
> >  wgl)
> > diff --git a/src/wgl/wglcontext.c b/src/wgl/wglcontext.c
> > new file mode 100644
> > index 000..41e44cd
> > --- /dev/null
> > +++ b/src/wgl/wglcontext.c
> > @@ -0,0 +1,274 @@
> > +/*
> > + * Copyright (C) 2011 Morgan Armand 
> > + *
> > + * 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 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 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 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +static LRESULT CALLBACK
> > +WndProc(HWND hWnd,
> > +UINT uMsg,
> > +WPARAM wParam,
> > +LPARAM lParam )
> > +{
> > +   switch (uMsg) {
> > +   case WM_DESTROY:
> > +  PostQuitMessage(0);
> > +  break;
> > +   default:
> > +  return DefWindowProc(hWnd, uMsg, wParam, lParam);
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> > +static char *
> > +context_error_to_string(DWORD error)
> > +{
> > +   switch (error) {
> > +   case ERROR_INVALID_VERSION_ARB:  return
> > "ERROR_INVALID_VERSION_ARB";
> > +   case ERROR_INVALID_PROFILE_ARB:  return
> > "ERROR_INVALID_PROFILE_ARB";
> > +   case ERROR_INVALID_OPERATION:return
> > "ERROR_INVALID_OPERATION";
> > +   case ERROR_DC_NOT_FOUND: return "ERROR_DC_NOT_FOUND";
> > +   case ERROR_INVALID_PIXEL_FORMAT: return
> > "ERROR_INVALID_PIXEL_FORMAT";
> > +   case ERROR_NO_SYSTEM_RESOURCES:  return
> > "ERROR_NO_SYSTEM_RESOURCES";
> > +   case ERROR_INVALID_PARAMETER:return
> > "ERROR_INVALID_PARAMETER";
> > +   default: return "Unknown Error";
> > +   }
> > +}
> > +
> > +static char *
> > +profile_mask_to_string(GLint profileMask)
> > +{
> > +   switch (profileMask) {
> > +   case WGL_CONTEXT_CORE_PROFILE_BIT_ARB:
> > +  return &

[Mesa-dev] [PATCH] wglSetPixelFormat should ignore the ppfd parameter

2011-11-02 Thread Morgan Armand

The patch should be correctly formatted, but I attached it anyway to be sure 
for this time.

---
 src/gallium/state_trackers/wgl/stw_wgl.c |3 +--
 src/mesa/drivers/windows/gdi/wgl.c   |6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/wgl/stw_wgl.c 
b/src/gallium/state_trackers/wgl/stw_wgl.c
index 5fbb7bf..2d34a03 100644
--- a/src/gallium/state_trackers/wgl/stw_wgl.c
+++ b/src/gallium/state_trackers/wgl/stw_wgl.c
@@ -172,8 +172,7 @@ wglSetPixelFormat(
int iPixelFormat,
const PIXELFORMATDESCRIPTOR *ppfd )
 {
-   if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ))
-  return FALSE;
+   (void) ppfd;

return DrvSetPixelFormat( hdc, iPixelFormat );
 }
diff --git a/src/mesa/drivers/windows/gdi/wgl.c 
b/src/mesa/drivers/windows/gdi/wgl.c
index 33baabe..6e78200 100644
--- a/src/mesa/drivers/windows/gdi/wgl.c
+++ b/src/mesa/drivers/windows/gdi/wgl.c
@@ -335,9 +335,9 @@ WINGDIAPI BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int 
iPixelFormat,
const PIXELFORMATDESCRIPTOR *ppfd)
 {
 (void) hdc;
-
-if(iPixelFormat < 1 || iPixelFormat > npfd ||
-   ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR)) {
+(void) ppfd;
+
+if(iPixelFormat < 1 || iPixelFormat > npfd) {
SetLastError(0);
return(FALSE);
 }
--
1.7.7.1.msysgit.0

>From 82313b22a319d04163113030b740268ef9e06e09 Mon Sep 17 00:00:00 2001
From: Morgan Armand 
Date: Wed, 2 Nov 2011 20:12:39 +0100
Subject: [PATCH 2/2] wglSetPixelFormat should ignore the ppfd parameter.

---
 src/gallium/state_trackers/wgl/stw_wgl.c |3 +--
 src/mesa/drivers/windows/gdi/wgl.c   |6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/wgl/stw_wgl.c 
b/src/gallium/state_trackers/wgl/stw_wgl.c
index 5fbb7bf..2d34a03 100644
--- a/src/gallium/state_trackers/wgl/stw_wgl.c
+++ b/src/gallium/state_trackers/wgl/stw_wgl.c
@@ -172,8 +172,7 @@ wglSetPixelFormat(
int iPixelFormat,
const PIXELFORMATDESCRIPTOR *ppfd )
 {
-   if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ))
-  return FALSE;
+   (void) ppfd;
 
return DrvSetPixelFormat( hdc, iPixelFormat );
 }
diff --git a/src/mesa/drivers/windows/gdi/wgl.c 
b/src/mesa/drivers/windows/gdi/wgl.c
index 33baabe..6e78200 100644
--- a/src/mesa/drivers/windows/gdi/wgl.c
+++ b/src/mesa/drivers/windows/gdi/wgl.c
@@ -335,9 +335,9 @@ WINGDIAPI BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int 
iPixelFormat,
const PIXELFORMATDESCRIPTOR *ppfd)
 {
 (void) hdc;
-
-if(iPixelFormat < 1 || iPixelFormat > npfd || 
-   ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR)) {
+(void) ppfd;
+
+if(iPixelFormat < 1 || iPixelFormat > npfd) {
SetLastError(0);
return(FALSE);
 }
-- 
1.7.7.1.msysgit.0

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


[Mesa-dev] [PATCH] softpipe: don't clamp or do logical operations on floating-point buffers.

2011-11-06 Thread Morgan Armand
---
 src/gallium/drivers/softpipe/sp_quad_blend.c |   78 ++---
 1 files changed, 56 insertions(+), 22 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c 
b/src/gallium/drivers/softpipe/sp_quad_blend.c
index 598df26..4813ada 100644
--- a/src/gallium/drivers/softpipe/sp_quad_blend.c
+++ b/src/gallium/drivers/softpipe/sp_quad_blend.c
@@ -702,19 +702,19 @@ blend_quad(struct quad_stage *qs,
 */
switch (softpipe->blend->rt[blend_index].rgb_func) {
case PIPE_BLEND_ADD:
-  VEC4_ADD_SAT(quadColor[0], source[0], blend_dest[0]); /* R */
-  VEC4_ADD_SAT(quadColor[1], source[1], blend_dest[1]); /* G */
-  VEC4_ADD_SAT(quadColor[2], source[2], blend_dest[2]); /* B */
+  VEC4_ADD(quadColor[0], source[0], blend_dest[0]); /* R */
+  VEC4_ADD(quadColor[1], source[1], blend_dest[1]); /* G */
+  VEC4_ADD(quadColor[2], source[2], blend_dest[2]); /* B */
   break;
case PIPE_BLEND_SUBTRACT:
-  VEC4_SUB_SAT(quadColor[0], source[0], blend_dest[0]); /* R */
-  VEC4_SUB_SAT(quadColor[1], source[1], blend_dest[1]); /* G */
-  VEC4_SUB_SAT(quadColor[2], source[2], blend_dest[2]); /* B */
+  VEC4_SUB(quadColor[0], source[0], blend_dest[0]); /* R */
+  VEC4_SUB(quadColor[1], source[1], blend_dest[1]); /* G */
+  VEC4_SUB(quadColor[2], source[2], blend_dest[2]); /* B */
   break;
case PIPE_BLEND_REVERSE_SUBTRACT:
-  VEC4_SUB_SAT(quadColor[0], blend_dest[0], source[0]); /* R */
-  VEC4_SUB_SAT(quadColor[1], blend_dest[1], source[1]); /* G */
-  VEC4_SUB_SAT(quadColor[2], blend_dest[2], source[2]); /* B */
+  VEC4_SUB(quadColor[0], blend_dest[0], source[0]); /* R */
+  VEC4_SUB(quadColor[1], blend_dest[1], source[1]); /* G */
+  VEC4_SUB(quadColor[2], blend_dest[2], source[2]); /* B */
   break;
case PIPE_BLEND_MIN:
   VEC4_MIN(quadColor[0], source[0], blend_dest[0]); /* R */
@@ -735,13 +735,13 @@ blend_quad(struct quad_stage *qs,
 */
switch (softpipe->blend->rt[blend_index].alpha_func) {
case PIPE_BLEND_ADD:
-  VEC4_ADD_SAT(quadColor[3], source[3], blend_dest[3]); /* A */
+  VEC4_ADD(quadColor[3], source[3], blend_dest[3]); /* A */
   break;
case PIPE_BLEND_SUBTRACT:
-  VEC4_SUB_SAT(quadColor[3], source[3], blend_dest[3]); /* A */
+  VEC4_SUB(quadColor[3], source[3], blend_dest[3]); /* A */
   break;
case PIPE_BLEND_REVERSE_SUBTRACT:
-  VEC4_SUB_SAT(quadColor[3], blend_dest[3], source[3]); /* A */
+  VEC4_SUB(quadColor[3], blend_dest[3], source[3]); /* A */
   break;
case PIPE_BLEND_MIN:
   VEC4_MIN(quadColor[3], source[3], blend_dest[3]); /* A */
@@ -856,6 +856,10 @@ blend_fallback(struct quad_stage *qs,

for (cbuf = 0; cbuf < softpipe->framebuffer.nr_cbufs; cbuf++)
{
+  const enum pipe_format format =
+ softpipe->framebuffer.cbufs[cbuf]->format;
+  const struct util_format_description *desc =
+ util_format_description(format);
   /* which blend/mask state index to use: */
   const uint blend_buf = blend->independent_blend_enable ? cbuf : 0;
   float dest[4][QUAD_SIZE];
@@ -909,10 +913,19 @@ blend_fallback(struct quad_stage *qs,


  if (blend->logicop_enable) {
-logicop_quad( qs, quadColor, dest );
+if (desc->channel[0].type != UTIL_FORMAT_TYPE_FLOAT) {
+   logicop_quad( qs, quadColor, dest );
+}
  }
  else if (blend->rt[blend_buf].blend_enable) {
 blend_quad(qs, quadColor, dest, blend_color, blend_buf);
+
+/* If fixed-point dest color buffer, need to clamp the outgoing
+ * fragment colors now.
+ */
+if (clamp) {
+   clamp_colors(quadColor);
+}
  }

  rebase_colors(bqs->base_format[cbuf], quadColor);
@@ -969,6 +982,13 @@ blend_single_add_src_alpha_inv_src_alpha(struct quad_stage 
*qs,
  }
   }

+  /* If fixed-point dest color buffer, need to clamp the incoming
+   * fragment colors now.
+   */
+  if (bqs->clamp[0]) {
+ clamp_colors(quadColor);
+  }
+
   VEC4_MUL(source[0], quadColor[0], alpha); /* R */
   VEC4_MUL(source[1], quadColor[1], alpha); /* G */
   VEC4_MUL(source[2], quadColor[2], alpha); /* B */
@@ -978,12 +998,19 @@ blend_single_add_src_alpha_inv_src_alpha(struct 
quad_stage *qs,
   VEC4_MUL(dest[0], dest[0], one_minus_alpha); /* R */
   VEC4_MUL(dest[1], dest[1], one_minus_alpha); /* G */
   VEC4_MUL(dest[2], dest[2], one_minus_alpha); /* B */
-  VEC4_MUL(dest[3], dest[3], one_minus_alpha); /* B */
+  VEC4_MUL(dest[3], dest[3], one_minus_alpha); /* A */

-  VEC4_ADD_SAT(quadColor[0], source[0], dest[0]); /* R */
-  VEC4_ADD_SAT(quadColor[1], source[1], dest[1]); /* G */
-  VEC4_ADD_SAT(quadColor[2], source[2], dest[2]); /* B */
-  VEC4_ADD_SAT(quadColor[3], source[3], dest[3]); /* A */
+  VEC4_ADD(quadColor[0]

Re: [Mesa-dev] [PATCH] softpipe: don't clamp or do logical operations on floating-point buffers.

2011-11-06 Thread Morgan Armand
Unless I'm missing something, no there is no ROPs defined for floating points 
operands.
The ARB_color_buffer_float specification says:

36. Should logical operations be disabled for floating-point color buffers?
RESOLVED:  Yes.  This matches the behavior in the ATI specification.

Besides that, the result of the blending equation is no longer clamped when 
dealing
with FP buffers.

On 11/6/2011 3:08 PM, Corbin Simpson wrote:
> It's entirely possible that I'm still asleep, but what problem does this 
> solve? Are ROPs not defined for FP operands?
> 
> Sending from a mobile, pardon my terseness. ~ C.
> 
> On Nov 6, 2011 4:31 AM, "Morgan Armand"  <mailto:morgan.de...@gmail.com>> wrote:
> 
> ---
>  src/gallium/drivers/softpipe/sp_quad_blend.c |   78 
> ++---
>  1 files changed, 56 insertions(+), 22 deletions(-)
> 
> diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c 
> b/src/gallium/drivers/softpipe/sp_quad_blend.c
> index 598df26..4813ada 100644
> --- a/src/gallium/drivers/softpipe/sp_quad_blend.c
> +++ b/src/gallium/drivers/softpipe/sp_quad_blend.c
> @@ -702,19 +702,19 @@ blend_quad(struct quad_stage *qs,
> */
>switch (softpipe->blend->rt[blend_index].rgb_func) {
>case PIPE_BLEND_ADD:
> -  VEC4_ADD_SAT(quadColor[0], source[0], blend_dest[0]); /* R */
> -  VEC4_ADD_SAT(quadColor[1], source[1], blend_dest[1]); /* G */
> -  VEC4_ADD_SAT(quadColor[2], source[2], blend_dest[2]); /* B */
> +  VEC4_ADD(quadColor[0], source[0], blend_dest[0]); /* R */
> +  VEC4_ADD(quadColor[1], source[1], blend_dest[1]); /* G */
> +  VEC4_ADD(quadColor[2], source[2], blend_dest[2]); /* B */
>   break;
>case PIPE_BLEND_SUBTRACT:
> -  VEC4_SUB_SAT(quadColor[0], source[0], blend_dest[0]); /* R */
> -  VEC4_SUB_SAT(quadColor[1], source[1], blend_dest[1]); /* G */
> -  VEC4_SUB_SAT(quadColor[2], source[2], blend_dest[2]); /* B */
> +  VEC4_SUB(quadColor[0], source[0], blend_dest[0]); /* R */
> +  VEC4_SUB(quadColor[1], source[1], blend_dest[1]); /* G */
> +  VEC4_SUB(quadColor[2], source[2], blend_dest[2]); /* B */
>   break;
>case PIPE_BLEND_REVERSE_SUBTRACT:
> -  VEC4_SUB_SAT(quadColor[0], blend_dest[0], source[0]); /* R */
> -  VEC4_SUB_SAT(quadColor[1], blend_dest[1], source[1]); /* G */
> -  VEC4_SUB_SAT(quadColor[2], blend_dest[2], source[2]); /* B */
> +  VEC4_SUB(quadColor[0], blend_dest[0], source[0]); /* R */
> +  VEC4_SUB(quadColor[1], blend_dest[1], source[1]); /* G */
> +  VEC4_SUB(quadColor[2], blend_dest[2], source[2]); /* B */
>   break;
>case PIPE_BLEND_MIN:
>   VEC4_MIN(quadColor[0], source[0], blend_dest[0]); /* R */
> @@ -735,13 +735,13 @@ blend_quad(struct quad_stage *qs,
> */
>switch (softpipe->blend->rt[blend_index].alpha_func) {
>case PIPE_BLEND_ADD:
> -  VEC4_ADD_SAT(quadColor[3], source[3], blend_dest[3]); /* A */
> +  VEC4_ADD(quadColor[3], source[3], blend_dest[3]); /* A */
>   break;
>case PIPE_BLEND_SUBTRACT:
> -  VEC4_SUB_SAT(quadColor[3], source[3], blend_dest[3]); /* A */
> +  VEC4_SUB(quadColor[3], source[3], blend_dest[3]); /* A */
>   break;
>case PIPE_BLEND_REVERSE_SUBTRACT:
> -  VEC4_SUB_SAT(quadColor[3], blend_dest[3], source[3]); /* A */
> +  VEC4_SUB(quadColor[3], blend_dest[3], source[3]); /* A */
>   break;
>case PIPE_BLEND_MIN:
>   VEC4_MIN(quadColor[3], source[3], blend_dest[3]); /* A */
> @@ -856,6 +856,10 @@ blend_fallback(struct quad_stage *qs,
> 
>for (cbuf = 0; cbuf < softpipe->framebuffer.nr_cbufs; cbuf++)
>{
> +  const enum pipe_format format =
> + softpipe->framebuffer.cbufs[cbuf]->format;
> +  const struct util_format_description *desc =
> + util_format_description(format);
>   /* which blend/mask state index to use: */
>   const uint blend_buf = blend->independent_blend_enable ? cbuf : 0;
>   float dest[4][QUAD_SIZE];
> @@ -909,10 +913,19 @@ blend_fallback(struct quad_stage *qs,
> 
> 
>  if (blend->logicop_enable) {
> -logicop_quad( qs, quadColor, dest );
> +if (desc->channel[0].type != UTIL_FORMAT_TYPE_FLOAT) {
> +   logicop_quad( qs, quadColor, dest );
> +}
>  }
>  else if (blend->rt[blend_buf].blend

[Mesa-dev] [PATCH] Fix memory leaks and some bad indentation

2011-11-06 Thread Morgan Armand
---
 src/gallium/drivers/softpipe/sp_state_derived.c |5 -
 src/gallium/drivers/softpipe/sp_state_shader.c  |3 +++
 src/mesa/state_tracker/st_atom_texture.c|   11 +--
 src/mesa/state_tracker/st_cb_drawpixels.c   |   10 +-
 4 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c 
b/src/gallium/drivers/softpipe/sp_state_derived.c
index fd68808..f89d23c 100644
--- a/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -295,9 +295,12 @@ update_polygon_stipple_pattern(struct softpipe_context 
*softpipe)
tex = util_pstipple_create_stipple_texture(&softpipe->pipe,
   softpipe->poly_stipple.stipple);
pipe_resource_reference(&softpipe->pstipple.texture, tex);
+   pipe_resource_reference(&tex, NULL);

-   view = util_pstipple_create_sampler_view(&softpipe->pipe, tex);
+   view = util_pstipple_create_sampler_view(&softpipe->pipe,
+softpipe->pstipple.texture);
pipe_sampler_view_reference(&softpipe->pstipple.sampler_view, view);
+   pipe_sampler_view_reference(&view, NULL);
 }


diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c 
b/src/gallium/drivers/softpipe/sp_state_shader.c
index 3dd1f9e..612dcb3 100644
--- a/src/gallium/drivers/softpipe/sp_state_shader.c
+++ b/src/gallium/drivers/softpipe/sp_state_shader.c
@@ -207,6 +207,7 @@ softpipe_delete_fs_state(struct pipe_context *pipe, void 
*fs)
draw_delete_fragment_shader(softpipe->draw, state->draw_shader);

FREE((void *) state->shader.tokens);
+   FREE(state);
 }


@@ -335,6 +336,8 @@ softpipe_delete_gs_state(struct pipe_context *pipe, void 
*gs)

draw_delete_geometry_shader(softpipe->draw,
(state) ? state->draw_data : 0);
+
+   FREE((void *) state->shader.tokens);
FREE(state);
 }

diff --git a/src/mesa/state_tracker/st_atom_texture.c 
b/src/mesa/state_tracker/st_atom_texture.c
index 3115a25..008e9bd 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -267,14 +267,13 @@ update_vertex_textures(struct st_context *st)
  GLboolean retval;
  GLuint texUnit;

-texUnit = vprog->Base.SamplerUnits[su];
+ texUnit = vprog->Base.SamplerUnits[su];

-retval = update_single_texture(st, &sampler_view, texUnit);
-if (retval == GL_FALSE)
-   continue;
-
-st->state.num_vertex_textures = su + 1;
+ retval = update_single_texture(st, &sampler_view, texUnit);
+ if (retval == GL_FALSE)
+continue;

+ st->state.num_vertex_textures = su + 1;
   }
   pipe_sampler_view_reference(&st->state.sampler_vertex_views[su], 
sampler_view);
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c 
b/src/mesa/state_tracker/st_cb_drawpixels.c
index 1c44d0d..5714d34 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1135,10 +1135,10 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
   assert(0);
}

-  sv[1] = st_create_texture_sampler_view_format(st->pipe, pt,
+   sv[1] = st_create_texture_sampler_view_format(st->pipe, pt,
  stencil_format);
-  num_sampler_view++;
-   }
+   num_sampler_view++;
+}

 draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2],
width, height,
@@ -1638,9 +1638,9 @@ st_destroy_drawpix(struct st_context *st)

st_reference_fragprog(st, &st->pixel_xfer.combined_prog, NULL);
if (st->drawpix.vert_shaders[0])
-  ureg_free_tokens(st->drawpix.vert_shaders[0]);
+  cso_delete_vertex_shader(st->cso_context, st->drawpix.vert_shaders[0]);
if (st->drawpix.vert_shaders[1])
-  ureg_free_tokens(st->drawpix.vert_shaders[1]);
+  cso_delete_vertex_shader(st->cso_context, st->drawpix.vert_shaders[1]);
 }

 #endif /* FEATURE_drawpix */
-- 
1.7.7.1.msysgit.0

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


[Mesa-dev] [PATCH 1/3] softpipe: fix memory leaks

2011-11-07 Thread Morgan Armand
This series of patches is a splitted version of my previous one, as suggested 
by Brian.

---
 src/gallium/drivers/softpipe/sp_state_derived.c |5 -
 src/gallium/drivers/softpipe/sp_state_shader.c  |3 +++
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c 
b/src/gallium/drivers/softpipe/sp_state_derived.c
index fd68808..f89d23c 100644
--- a/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -295,9 +295,12 @@ update_polygon_stipple_pattern(struct softpipe_context 
*softpipe)
tex = util_pstipple_create_stipple_texture(&softpipe->pipe,
   softpipe->poly_stipple.stipple);
pipe_resource_reference(&softpipe->pstipple.texture, tex);
+   pipe_resource_reference(&tex, NULL);

-   view = util_pstipple_create_sampler_view(&softpipe->pipe, tex);
+   view = util_pstipple_create_sampler_view(&softpipe->pipe,
+softpipe->pstipple.texture);
pipe_sampler_view_reference(&softpipe->pstipple.sampler_view, view);
+   pipe_sampler_view_reference(&view, NULL);
 }


diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c 
b/src/gallium/drivers/softpipe/sp_state_shader.c
index 3dd1f9e..612dcb3 100644
--- a/src/gallium/drivers/softpipe/sp_state_shader.c
+++ b/src/gallium/drivers/softpipe/sp_state_shader.c
@@ -207,6 +207,7 @@ softpipe_delete_fs_state(struct pipe_context *pipe, void 
*fs)
draw_delete_fragment_shader(softpipe->draw, state->draw_shader);

FREE((void *) state->shader.tokens);
+   FREE(state);
 }


@@ -335,6 +336,8 @@ softpipe_delete_gs_state(struct pipe_context *pipe, void 
*gs)

draw_delete_geometry_shader(softpipe->draw,
(state) ? state->draw_data : 0);
+
+   FREE((void *) state->shader.tokens);
FREE(state);
 }

-- 
1.7.7.1.msysgit.0

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


[Mesa-dev] [PATCH 2/3] st/mesa: fix indentation

2011-11-07 Thread Morgan Armand
---
 src/mesa/state_tracker/st_atom_texture.c  |   11 +--
 src/mesa/state_tracker/st_cb_drawpixels.c |6 +++---
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_texture.c 
b/src/mesa/state_tracker/st_atom_texture.c
index 3115a25..008e9bd 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -267,14 +267,13 @@ update_vertex_textures(struct st_context *st)
  GLboolean retval;
  GLuint texUnit;

-texUnit = vprog->Base.SamplerUnits[su];
+ texUnit = vprog->Base.SamplerUnits[su];

-retval = update_single_texture(st, &sampler_view, texUnit);
-if (retval == GL_FALSE)
-   continue;
-
-st->state.num_vertex_textures = su + 1;
+ retval = update_single_texture(st, &sampler_view, texUnit);
+ if (retval == GL_FALSE)
+continue;

+ st->state.num_vertex_textures = su + 1;
   }
   pipe_sampler_view_reference(&st->state.sampler_vertex_views[su], 
sampler_view);
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c 
b/src/mesa/state_tracker/st_cb_drawpixels.c
index 1c44d0d..8c49f8d 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1135,10 +1135,10 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
   assert(0);
}

-  sv[1] = st_create_texture_sampler_view_format(st->pipe, pt,
+   sv[1] = st_create_texture_sampler_view_format(st->pipe, pt,
  stencil_format);
-  num_sampler_view++;
-   }
+   num_sampler_view++;
+}

 draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2],
width, height,
-- 
1.7.7.1.msysgit.0

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


[Mesa-dev] [PATCH 3/3] st/mesa: fix memory leaks

2011-11-07 Thread Morgan Armand
---
 src/mesa/state_tracker/st_cb_drawpixels.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c 
b/src/mesa/state_tracker/st_cb_drawpixels.c
index 8c49f8d..5714d34 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1638,9 +1638,9 @@ st_destroy_drawpix(struct st_context *st)

st_reference_fragprog(st, &st->pixel_xfer.combined_prog, NULL);
if (st->drawpix.vert_shaders[0])
-  ureg_free_tokens(st->drawpix.vert_shaders[0]);
+  cso_delete_vertex_shader(st->cso_context, st->drawpix.vert_shaders[0]);
if (st->drawpix.vert_shaders[1])
-  ureg_free_tokens(st->drawpix.vert_shaders[1]);
+  cso_delete_vertex_shader(st->cso_context, st->drawpix.vert_shaders[1]);
 }

 #endif /* FEATURE_drawpix */
-- 
1.7.7.1.msysgit.0

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


Re: [Mesa-dev] [PATCH] softpipe: don't clamp or do logical operations on floating-point buffers.

2011-11-07 Thread Morgan Armand
4_ADD_SAT(quadColor[3], source[3], dest[3]); /* A */
+  /* If fixed-point dest color buffer, need to clamp the outgoing
+   * fragment colors now.
+   */
+  if (bqs->clamp[0]) {
+ clamp_colors(quadColor);
+  }

   rebase_colors(bqs->base_format[0], quadColor);

@@ -1035,10 +1059,17 @@ blend_single_add_one_one(struct quad_stage *qs,
  clamp_colors(quadColor);
   }

-  VEC4_ADD_SAT(quadColor[0], quadColor[0], dest[0]); /* R */
-  VEC4_ADD_SAT(quadColor[1], quadColor[1], dest[1]); /* G */
-  VEC4_ADD_SAT(quadColor[2], quadColor[2], dest[2]); /* B */
-  VEC4_ADD_SAT(quadColor[3], quadColor[3], dest[3]); /* A */
+  VEC4_ADD(quadColor[0], quadColor[0], dest[0]); /* R */
+  VEC4_ADD(quadColor[1], quadColor[1], dest[1]); /* G */
+  VEC4_ADD(quadColor[2], quadColor[2], dest[2]); /* B */
+  VEC4_ADD(quadColor[3], quadColor[3], dest[3]); /* A */
+
+  /* If fixed-point dest color buffer, need to clamp the outgoing
+   * fragment colors now.
+   */
+  if (bqs->clamp[0]) {
+ clamp_colors(quadColor);
+  }

   rebase_colors(bqs->base_format[0], quadColor);

@@ -1150,6 +1181,7 @@ choose_blend_quad(struct quad_stage *qs,
  util_format_description(format);
   /* assuming all or no color channels are normalized: */
   bqs->clamp[i] = desc->channel[0].normalized;
+  bqs->format_type[i] = desc->channel[0].type;

   if (util_format_is_intensity(format))
  bqs->base_format[i] = INTENSITY;
-- 
1.7.7.1.msysgit.0


On 11/7/2011 4:38 PM, Brian Paul wrote:
> On 11/06/2011 05:31 AM, Morgan Armand wrote:
>> ---
>>   src/gallium/drivers/softpipe/sp_quad_blend.c |   78 
>> ++---
>>   1 files changed, 56 insertions(+), 22 deletions(-)
>>
>> diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c 
>> b/src/gallium/drivers/softpipe/sp_quad_blend.c
>> index 598df26..4813ada 100644
>> --- a/src/gallium/drivers/softpipe/sp_quad_blend.c
>> +++ b/src/gallium/drivers/softpipe/sp_quad_blend.c
>> @@ -702,19 +702,19 @@ blend_quad(struct quad_stage *qs,
>>   */
>>  switch (softpipe->blend->rt[blend_index].rgb_func) {
>>  case PIPE_BLEND_ADD:
>> -  VEC4_ADD_SAT(quadColor[0], source[0], blend_dest[0]); /* R */
>> -  VEC4_ADD_SAT(quadColor[1], source[1], blend_dest[1]); /* G */
>> -  VEC4_ADD_SAT(quadColor[2], source[2], blend_dest[2]); /* B */
>> +  VEC4_ADD(quadColor[0], source[0], blend_dest[0]); /* R */
>> +  VEC4_ADD(quadColor[1], source[1], blend_dest[1]); /* G */
>> +  VEC4_ADD(quadColor[2], source[2], blend_dest[2]); /* B */
>> break;
>>  case PIPE_BLEND_SUBTRACT:
>> -  VEC4_SUB_SAT(quadColor[0], source[0], blend_dest[0]); /* R */
>> -  VEC4_SUB_SAT(quadColor[1], source[1], blend_dest[1]); /* G */
>> -  VEC4_SUB_SAT(quadColor[2], source[2], blend_dest[2]); /* B */
>> +  VEC4_SUB(quadColor[0], source[0], blend_dest[0]); /* R */
>> +  VEC4_SUB(quadColor[1], source[1], blend_dest[1]); /* G */
>> +  VEC4_SUB(quadColor[2], source[2], blend_dest[2]); /* B */
>> break;
>>  case PIPE_BLEND_REVERSE_SUBTRACT:
>> -  VEC4_SUB_SAT(quadColor[0], blend_dest[0], source[0]); /* R */
>> -  VEC4_SUB_SAT(quadColor[1], blend_dest[1], source[1]); /* G */
>> -  VEC4_SUB_SAT(quadColor[2], blend_dest[2], source[2]); /* B */
>> +  VEC4_SUB(quadColor[0], blend_dest[0], source[0]); /* R */
>> +  VEC4_SUB(quadColor[1], blend_dest[1], source[1]); /* G */
>> +  VEC4_SUB(quadColor[2], blend_dest[2], source[2]); /* B */
>> break;
>>  case PIPE_BLEND_MIN:
>> VEC4_MIN(quadColor[0], source[0], blend_dest[0]); /* R */
>> @@ -735,13 +735,13 @@ blend_quad(struct quad_stage *qs,
>>   */
>>  switch (softpipe->blend->rt[blend_index].alpha_func) {
>>  case PIPE_BLEND_ADD:
>> -  VEC4_ADD_SAT(quadColor[3], source[3], blend_dest[3]); /* A */
>> +  VEC4_ADD(quadColor[3], source[3], blend_dest[3]); /* A */
>> break;
>>  case PIPE_BLEND_SUBTRACT:
>> -  VEC4_SUB_SAT(quadColor[3], source[3], blend_dest[3]); /* A */
>> +  VEC4_SUB(quadColor[3], source[3], blend_dest[3]); /* A */
>> break;
>>  case PIPE_BLEND_REVERSE_SUBTRACT:
>> -  VEC4_SUB_SAT(quadColor[3], blend_dest[3], source[3]); /* A */
>> +  VEC4_SUB(quadColor[3], blend_dest[3], source[3]); /* A */
>> break;
>>  case PIPE_BLEND_MIN:
>> VEC4_MIN(quadColor[3], source[3], blend_dest[3]); /* A */
>> @@ -856,6 +856,10 @@ blend_fallback(struct quad_stage *qs,
>>
>>  for (cbuf = 0; cbuf<  s

[Mesa-dev] [PATCH] softpipe: fix incorrect front-facing value.

2011-11-10 Thread Morgan Armand
Because the type of the facing attribute is unsigned, the whole computation was
done in the unsigned range.

Fixes fbo-fragcoord2, glsl1-gl_FrontFacing var (2) and glsl-fs-frontfacing 
tests.

---
 src/gallium/drivers/softpipe/sp_fs_exec.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_fs_exec.c 
b/src/gallium/drivers/softpipe/sp_fs_exec.c
index 779b8c4..cf19696 100644
--- a/src/gallium/drivers/softpipe/sp_fs_exec.c
+++ b/src/gallium/drivers/softpipe/sp_fs_exec.c
@@ -128,7 +128,7 @@ exec_run( const struct sp_fragment_shader_variant *var,
 &machine->QuadPos);

/* convert 0 to 1.0 and 1 to -1.0 */
-   machine->Face = (float) (quad->input.facing * -2 + 1);
+   machine->Face = (float) ((signed)quad->input.facing * -2 + 1);

quad->inout.mask &= tgsi_exec_machine_run( machine );
if (quad->inout.mask == 0)
-- 
1.7.7.1.msysgit.0

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


[Mesa-dev] [PATCH] glcpp: Add GL_ARB_draw_instanced #define.

2011-11-11 Thread Morgan Armand
---
 src/glsl/glcpp/glcpp-parse.y |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 1b17ff4..c0457b0 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -1132,6 +1132,9 @@ glcpp_parser_create (const struct gl_extensions 
*extensions, int api)
   if (extensions->ARB_shader_texture_lod)
  add_builtin_define(parser, "GL_ARB_shader_texture_lod", 1);

+  if (extensions->ARB_draw_instanced)
+ add_builtin_define(parser, "GL_ARB_draw_instanced", 1);
+
   if (extensions->AMD_conservative_depth) {
  add_builtin_define(parser, "GL_AMD_conservative_depth", 1);
  add_builtin_define(parser, "GL_ARB_conservative_depth", 1);
-- 
1.7.7.1.msysgit.0

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


[Mesa-dev] [PATCH] softpipe: fix clamping when using unormalized coordinates

2011-11-13 Thread Morgan Armand
---
 src/gallium/drivers/softpipe/sp_tex_sample.c |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c 
b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 72629a0..9b0e54e1 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -491,7 +491,8 @@ wrap_linear_unorm_clamp(const float s[4], unsigned size,
uint ch;
for (ch = 0; ch < 4; ch++) {
   /* Not exactly what the spec says, but it matches NVIDIA output */
-  float u = CLAMP(s[ch] - 0.5F, 0.0f, (float) size - 1.0f);
+  float u = CLAMP(s[ch], 0.0f, (float) size);
+  u -= 0.5F;
   icoord0[ch] = util_ifloor(u);
   icoord1[ch] = icoord0[ch] + 1;
   w[ch] = frac(u);
@@ -512,8 +513,8 @@ wrap_linear_unorm_clamp_to_border(const float s[4], 
unsigned size,
   u -= 0.5F;
   icoord0[ch] = util_ifloor(u);
   icoord1[ch] = icoord0[ch] + 1;
-  if (icoord1[ch] > (int) size - 1)
- icoord1[ch] = size - 1;
+  if (icoord1[ch] > (int) size)
+ icoord1[ch] = size;
   w[ch] = frac(u);
}
 }
-- 
1.7.7.1.msysgit.0

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


Re: [Mesa-dev] [PATCH] softpipe: fix clamping when using unormalized coordinates

2011-11-14 Thread Morgan Armand
On 11/14/2011 3:44 PM, Brian Paul wrote:
> On 11/13/2011 03:24 AM, Morgan Armand wrote:
>> ---
>>   src/gallium/drivers/softpipe/sp_tex_sample.c |7 ---
>>   1 files changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c 
>> b/src/gallium/drivers/softpipe/sp_tex_sample.c
>> index 72629a0..9b0e54e1 100644
>> --- a/src/gallium/drivers/softpipe/sp_tex_sample.c
>> +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
>> @@ -491,7 +491,8 @@ wrap_linear_unorm_clamp(const float s[4], unsigned size,
>>  uint ch;
>>  for (ch = 0; ch<  4; ch++) {
>> /* Not exactly what the spec says, but it matches NVIDIA output */
>> -  float u = CLAMP(s[ch] - 0.5F, 0.0f, (float) size - 1.0f);
>> +  float u = CLAMP(s[ch], 0.0f, (float) size);
>> +  u -= 0.5F;
>> icoord0[ch] = util_ifloor(u);
> 
> If s=0, then icoord0 = -1 and that's not right.  The 'i' coordinates must be 
> in the range [0,size-1].
> 
> Are you trying to fix a specific bug or piglit test?
> 
> 
>> icoord1[ch] = icoord0[ch] + 1;
>> w[ch] = frac(u);
>> @@ -512,8 +513,8 @@ wrap_linear_unorm_clamp_to_border(const float s[4], 
>> unsigned size,
>> u -= 0.5F;
>> icoord0[ch] = util_ifloor(u);
>> icoord1[ch] = icoord0[ch] + 1;
>> -  if (icoord1[ch]>  (int) size - 1)
>> - icoord1[ch] = size - 1;
>> +  if (icoord1[ch]>  (int) size)
>> + icoord1[ch] = size;
>> w[ch] = frac(u);
>>  }
>>   }
> 
> -Brian

Yes, sorry, I forgot to mention it. This patch fixes texwrap-RECT-bordercolor 
and texwrap-RECT-proj-bordercolor.

>From what I understand from the spec, we expect to get the border color when 
>sampling with out-of-range coordinates, or the
correct interpolation between the border color and the texel color when 
sampling with coordinates in the range [0; 1/2N[ or
[1-1/2N; max[. That's why I converted the coordinates to [-1;size] instead. 
get_texel_*d functions handle the case when a texture
coordinate is out-of-range but it may not the case of all functions so I 
probably need to check that carefully.
Please correct me if I misunderstood something.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] softpipe: fix clamping when using unormalized coordinates

2011-11-14 Thread Morgan Armand
On 11/14/2011 6:40 PM, Brian Paul wrote:
> On 11/14/2011 10:24 AM, Morgan Armand wrote:
>> On 11/14/2011 3:44 PM, Brian Paul wrote:
>>> On 11/13/2011 03:24 AM, Morgan Armand wrote:
>>>> ---
>>>>src/gallium/drivers/softpipe/sp_tex_sample.c |7 ---
>>>>1 files changed, 4 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c 
>>>> b/src/gallium/drivers/softpipe/sp_tex_sample.c
>>>> index 72629a0..9b0e54e1 100644
>>>> --- a/src/gallium/drivers/softpipe/sp_tex_sample.c
>>>> +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
>>>> @@ -491,7 +491,8 @@ wrap_linear_unorm_clamp(const float s[4], unsigned 
>>>> size,
>>>>   uint ch;
>>>>   for (ch = 0; ch<   4; ch++) {
>>>>  /* Not exactly what the spec says, but it matches NVIDIA output */
>>>> -  float u = CLAMP(s[ch] - 0.5F, 0.0f, (float) size - 1.0f);
>>>> +  float u = CLAMP(s[ch], 0.0f, (float) size);
>>>> +  u -= 0.5F;
>>>>  icoord0[ch] = util_ifloor(u);
>>>
>>> If s=0, then icoord0 = -1 and that's not right.  The 'i' coordinates must 
>>> be in the range [0,size-1].
>>>
>>> Are you trying to fix a specific bug or piglit test?
>>>
>>>
>>>>  icoord1[ch] = icoord0[ch] + 1;
>>>>  w[ch] = frac(u);
>>>> @@ -512,8 +513,8 @@ wrap_linear_unorm_clamp_to_border(const float s[4], 
>>>> unsigned size,
>>>>  u -= 0.5F;
>>>>  icoord0[ch] = util_ifloor(u);
>>>>  icoord1[ch] = icoord0[ch] + 1;
>>>> -  if (icoord1[ch]>   (int) size - 1)
>>>> - icoord1[ch] = size - 1;
>>>> +  if (icoord1[ch]>   (int) size)
>>>> + icoord1[ch] = size;
>>>>  w[ch] = frac(u);
>>>>   }
>>>>}
>>>
>>> -Brian
>>
>> Yes, sorry, I forgot to mention it. This patch fixes 
>> texwrap-RECT-bordercolor and texwrap-RECT-proj-bordercolor.
>>
>>  From what I understand from the spec, we expect to get the border color 
>> when sampling with out-of-range coordinates, or the
>> correct interpolation between the border color and the texel color when 
>> sampling with coordinates in the range [0; 1/2N[ or
>> [1-1/2N; max[. That's why I converted the coordinates to [-1;size] instead. 
>> get_texel_*d functions handle the case when a texture
>> coordinate is out-of-range but it may not the case of all functions so I 
>> probably need to check that carefully.
>> Please correct me if I misunderstood something.
> 
> I think I was wrong above.  I thought you were changing the clamp-to-edge 
> behaviour, but that case is implemented in the 
> wrap_linear_unorm_clamp_to_edge() function.
> 
> In any case, I remember that implementing what the spec says didn't match the 
> output from NVIDIA's driver (hence the comment there).
> 
> Do you have an NVIDIA GPU to compare against?
> 
> I could do some testing/comparing later...
> 
> -Brian

Yes I have, and AFAICT the results are identical (pixel-perfect, in fact). I've 
made the test on a windows machine, with the last
drivers.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev