Mesa (master): scons: Make LLVM a black-white dependency.

2010-04-11 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: ea532f0e725bd68e7784189c9b7f6f7bf7f9d901
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ea532f0e725bd68e7784189c9b7f6f7bf7f9d901

Author: José Fonseca 
Date:   Sat Apr 10 02:41:39 2010 +0100

scons: Make LLVM a black-white dependency.

Now that draw depends on llvm it is very difficult to correctly handle
broken llvm installations. Either the user requests LLVM and it needs to
supply a working installation. Or it doesn't, and it gets no LLVM
accelerate pipe drivers.

---

 SConstruct   |   14 --
 common.py|8 +++-
 configs/linux-llvm   |2 +-
 scons/gallium.py |6 --
 scons/llvm.py|   18 +++---
 src/gallium/auxiliary/SConscript |2 +-
 src/gallium/auxiliary/draw/draw_context.h|2 +-
 src/gallium/auxiliary/draw/draw_llvm.h   |4 ++--
 src/gallium/auxiliary/draw/draw_private.h|4 ++--
 src/gallium/auxiliary/draw/draw_pt.c |2 +-
 src/gallium/auxiliary/draw/draw_vs_llvm.c|2 +-
 src/gallium/auxiliary/gallivm/lp_bld.h   |4 ++--
 src/gallium/drivers/llvmpipe/SConscript  |9 -
 src/gallium/drivers/sw/SConscript|8 +++-
 src/gallium/state_trackers/python/SConscript |1 -
 src/gallium/targets/dri-swrast/SConscript|8 +++-
 src/gallium/targets/graw-xlib/SConscript |8 +++-
 src/gallium/targets/libgl-gdi/SConscript |6 ++
 src/gallium/targets/libgl-xlib/SConscript|8 +++-
 19 files changed, 51 insertions(+), 65 deletions(-)

diff --git a/SConstruct b/SConstruct
index 8b7ae7d..ebced16 100644
--- a/SConstruct
+++ b/SConstruct
@@ -81,15 +81,6 @@ debug = env['debug']
 dri = env['dri']
 machine = env['machine']
 platform = env['platform']
-drawllvm = 'llvmpipe' in env['drivers']
-
-# LLVM support in the Draw module
-if drawllvm:
-env.Tool('llvm')
-if not env.has_key('LLVM_VERSION'):
-   drawllvm = False
-if drawllvm:
-env.Append(CFLAGS = ['-DDRAW_LLVM=1'])
 
 # derived options
 x86 = machine == 'x86'
@@ -102,7 +93,6 @@ Export([
'x86', 
'ppc', 
'dri', 
-   'drawllvm',
'platform',
'gcc',
'msvc',
@@ -167,10 +157,6 @@ if platform in ('posix', 'linux', 'freebsd', 'darwin'):
'dl',
])
 
-# LLVM support in the Draw module
-if drawllvm:
-env.Append(CPPDEFINES = ['DRAW_LLVM'])
-
 # for debugging
 #print env.Dump()
 
diff --git a/common.py b/common.py
index 97389ed..4b6960c 100644
--- a/common.py
+++ b/common.py
@@ -3,6 +3,7 @@
 
 import os
 import os.path
+import subprocess
 import sys
 import platform as _platform
 
@@ -33,6 +34,11 @@ else:
default_machine = _platform.machine()
 default_machine = _machine_map.get(default_machine, 'generic')
 
+if 'LLVM' in os.environ or subprocess.call(['llvm-config', '--version'], 
stdout=subprocess.PIPE) == 0:
+default_llvm = 'yes'
+else:
+default_llvm = 'no'
+
 if default_platform in ('linux', 'freebsd'):
default_dri = 'yes'
 elif default_platform in ('winddk', 'windows', 'wince', 'darwin'):
@@ -61,5 +67,5 @@ def AddOptions(opts):
opts.Add(EnumOption('platform', 'target platform', default_platform,

 allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 
'darwin', 'embedded')))
opts.Add('toolchain', 'compiler toolchain', 'default')
-   opts.Add(BoolOption('llvm', 'use LLVM', 'no'))
+   opts.Add(BoolOption('llvm', 'use LLVM', default_llvm))
opts.Add(BoolOption('dri', 'build DRI drivers', default_dri))
diff --git a/configs/linux-llvm b/configs/linux-llvm
index 3a15f1d..1b15a30 100644
--- a/configs/linux-llvm
+++ b/configs/linux-llvm
@@ -12,7 +12,7 @@ GALLIUM_DRIVERS_DIRS += llvmpipe
 OPT_FLAGS = -O3 -ansi -pedantic
 ARCH_FLAGS = -mmmx -msse -msse2 -mstackrealign
 
-DEFINES += -DNDEBUG -DGALLIUM_LLVMPIPE -DDRAW_LLVM -DHAVE_UDIS86
+DEFINES += -DNDEBUG -DGALLIUM_LLVMPIPE -DHAVE_UDIS86
 
 # override -std=c99
 CFLAGS += -std=gnu99
diff --git a/scons/gallium.py b/scons/gallium.py
index 925effc..dd72754 100644
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -142,8 +142,6 @@ def generate(env):
 # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
 build_topdir = 'build'
 build_subdir = env['platform']
-if env['llvm']:
-build_subdir += "-llvm"
 if env['machine'] != 'generic':
 build_subdir += '-' + env['machine']
 if env['debug']:
@@ -471,6 +469,10 @@ def generate(env):
 # Default libs
 env.Append(LIBS = [])
 
+# Load LLVM
+if env['llvm']:
+env.Tool('llvm')
+
 # Custom builders and methods
 env.Tool('custom')
 createInstallMethods(env)
diff --git a/scons/llvm.py b/scons/llv

Mesa (master): scons: Make debug build default.

2010-04-11 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 21780adc2ed1b10c5c4c71427b8212b8464d065d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=21780adc2ed1b10c5c4c71427b8212b8464d065d

Author: José Fonseca 
Date:   Sat Apr 10 02:44:52 2010 +0100

scons: Make debug build default.

I've been back and forth on this, but I believe it's worth to have debug
by default.

Most humans (developers, testers) will want to use the debug version  by
default.  Many build bots want release but they are bots, and humans >
bots, so I don't care that much.

This is part of my initiative of minimizing the scons option mess many
complain about.

---

 common.py |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/common.py b/common.py
index 4b6960c..8372176 100644
--- a/common.py
+++ b/common.py
@@ -59,7 +59,7 @@ def AddOptions(opts):
from SCons.Variables.EnumVariable import EnumVariable as 
EnumOption
except ImportError:
from SCons.Options.EnumOption import EnumOption
-   opts.Add(BoolOption('debug', 'debug build', 'no'))
+   opts.Add(BoolOption('debug', 'debug build', 'yes'))
opts.Add(BoolOption('profile', 'profile build', 'no'))
opts.Add(BoolOption('quiet', 'quiet command lines', 'yes'))
opts.Add(EnumOption('machine', 'use machine-specific assembly code', 
default_machine,

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


Mesa (master): scons: Always build softpipe and llvmpipe ( when llvm available).

2010-04-11 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 47a89e9255846f55efe0992c94b65ae7c911dbb3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=47a89e9255846f55efe0992c94b65ae7c911dbb3

Author: José Fonseca 
Date:   Sat Apr 10 03:01:30 2010 +0100

scons: Always build softpipe and llvmpipe (when llvm available).

These are our reference software rasterizers. They can build everywhere
and are a precious debugging tool.

Making them always present immensily simplifies the scons logic.

If people want to avoid building it is still possible to pass
direcotries and target names to scons to narrow the build.

---

 SConstruct   |6 +-
 src/gallium/drivers/sw/SConscript|8 ++--
 src/gallium/state_trackers/python/SConscript |4 ++--
 src/gallium/targets/dri-swrast/SConscript|8 ++--
 src/gallium/targets/graw-xlib/SConscript |8 ++--
 src/gallium/targets/libgl-gdi/SConscript |8 ++--
 src/gallium/targets/libgl-xlib/SConscript|8 ++--
 7 files changed, 17 insertions(+), 33 deletions(-)

diff --git a/SConstruct b/SConstruct
index ebced16..fdcd72b 100644
--- a/SConstruct
+++ b/SConstruct
@@ -102,11 +102,15 @@ Export([
 ###
 # Environment setup
 
-# Always build trace and identity drivers
+# Always build trace, identity, softpipe, and llvmpipe (where possible)
 if 'trace' not in env['drivers']:
 env['drivers'].append('trace')
 if 'identity' not in env['drivers']:
 env['drivers'].append('identity')
+if 'softpipe' not in env['drivers']:
+env['drivers'].append('softpipe')
+if env['llvm'] and 'llvmpipe' not in env['drivers']:
+env['drivers'].append('llvmpipe')
 
 # Includes
 env.Append(CPPPATH = [
diff --git a/src/gallium/drivers/sw/SConscript 
b/src/gallium/drivers/sw/SConscript
index cea237a..37d0a0d 100644
--- a/src/gallium/drivers/sw/SConscript
+++ b/src/gallium/drivers/sw/SConscript
@@ -12,17 +12,13 @@
 
 Import('*')
 
-if not set(('softpipe', 'llvmpipe', 'cell')).intersection(env['drivers']):
-print 'warning: no supported pipe driver: skipping build of sw meta-driver'
-Return()
-
 env = env.Clone()
 
-if 'softpipe' in env['drivers']:
+if True:
 env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE')
 env.Prepend(LIBS = [softpipe])
 
-if 'llvmpipe' in env['drivers']:
+if env['llvm']:
 env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
 env.Tool('udis86')
 env.Prepend(LIBS = [llvmpipe])
diff --git a/src/gallium/state_trackers/python/SConscript 
b/src/gallium/state_trackers/python/SConscript
index bff9707..aadeaa0 100644
--- a/src/gallium/state_trackers/python/SConscript
+++ b/src/gallium/state_trackers/python/SConscript
@@ -44,10 +44,10 @@ if 'python' in env['statetrackers']:
 gallium,
 ])
 
-if 'llvmpipe' in env['drivers']:
+if env['llvm']:
 env.Append(CPPDEFINES = ['HAVE_LLVMPIPE'])
 env.Prepend(LIBS = [llvmpipe])
-if 'softpipe' in env['drivers']:
+if True:
 env.Append(CPPDEFINES = ['HAVE_SOFTPIPE'])
 env.Prepend(LIBS = [softpipe])
 
diff --git a/src/gallium/targets/dri-swrast/SConscript 
b/src/gallium/targets/dri-swrast/SConscript
index 9a3838d..77f4438 100644
--- a/src/gallium/targets/dri-swrast/SConscript
+++ b/src/gallium/targets/dri-swrast/SConscript
@@ -1,9 +1,5 @@
 Import('*')
 
-if not set(('softpipe', 'llvmpipe')).intersection(env['drivers']):
-print 'warning: no supported pipe driver: skipping build of swrastg_dri.so'
-Return()
-
 env = drienv.Clone()
 
 env.Append(CPPPATH = [
@@ -20,11 +16,11 @@ env.Prepend(LIBS = [
 COMMON_DRI_SW_OBJECTS
 ])
 
-if 'softpipe' in env['drivers']:
+if True:
 env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE')
 env.Prepend(LIBS = [softpipe])
 
-if 'llvmpipe' in env['drivers']:
+if env['llvm']:
 env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
 env.Tool('udis86')
 env.Prepend(LIBS = [llvmpipe])
diff --git a/src/gallium/targets/graw-xlib/SConscript 
b/src/gallium/targets/graw-xlib/SConscript
index 1b5350a..979252b 100644
--- a/src/gallium/targets/graw-xlib/SConscript
+++ b/src/gallium/targets/graw-xlib/SConscript
@@ -6,10 +6,6 @@ Import('*')
 if env['platform'] != 'linux':
 Return()
 
-if not set(('softpipe', 'llvmpipe', 'cell')).intersection(env['drivers']):
-print 'warning: no supported pipe driver: skipping build of xlib libGL.so'
-Return()
-
 env = env.Clone()
 
 env.Prepend(LIBS = [
@@ -28,11 +24,11 @@ sources = [
 'graw_xlib.c',
 ]
 
-if 'softpipe' in env['drivers']:
+if True:
 env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE')
 env.Prepend(LIBS = [softpipe])
 
-if 'llvmpipe' in env['drivers']:
+if env['llvm']:
 env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
 env.Tool('udis86')
 env.Prepend(LIBS = [llvmpipe])
diff --git a/src/gallium/targets/libgl-gdi/SConscript 
b/src/gallium/targets/libgl-gdi/SConscript
index a6ef1f2..2a55c7a 100644
--- a/src/gallium/targets/libgl-gdi/SConscript
+++ 

Mesa (master): st/wgl: Switch from st_public.h to st_api.h. [V2]

2010-04-11 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 192f06adca5e79b4824d92dc41186592ed57f71e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=192f06adca5e79b4824d92dc41186592ed57f71e

Author: Chia-I Wu 
Date:   Wed Mar 17 10:11:22 2010 +0800

st/wgl: Switch from st_public.h to st_api.h. [V2]

This is only compile tested with crossmingw.

V2:
 - reference count stw_framebuffer

---

 src/gallium/state_trackers/wgl/SConscript  |1 +
 src/gallium/state_trackers/wgl/stw_context.c   |  125 
 src/gallium/state_trackers/wgl/stw_context.h   |   10 +-
 src/gallium/state_trackers/wgl/stw_device.c|   43 +--
 src/gallium/state_trackers/wgl/stw_device.h|5 +
 .../state_trackers/wgl/stw_ext_pixelformat.c   |4 +-
 src/gallium/state_trackers/wgl/stw_framebuffer.c   |   99 +++
 src/gallium/state_trackers/wgl/stw_framebuffer.h   |   18 +-
 src/gallium/state_trackers/wgl/stw_pixelformat.c   |   47 +--
 src/gallium/state_trackers/wgl/stw_pixelformat.h   |   11 +-
 src/gallium/state_trackers/wgl/stw_st.c|  306 
 src/gallium/state_trackers/wgl/stw_st.h|   47 +++
 12 files changed, 519 insertions(+), 197 deletions(-)

diff --git a/src/gallium/state_trackers/wgl/SConscript 
b/src/gallium/state_trackers/wgl/SConscript
index 352c087..f59f3a9 100644
--- a/src/gallium/state_trackers/wgl/SConscript
+++ b/src/gallium/state_trackers/wgl/SConscript
@@ -28,6 +28,7 @@ if env['platform'] in ['windows']:
 'stw_framebuffer.c',
 'stw_getprocaddress.c',
 'stw_pixelformat.c',
+'stw_st.c',
 'stw_tls.c',
 'stw_wgl.c',
 ]
diff --git a/src/gallium/state_trackers/wgl/stw_context.c 
b/src/gallium/state_trackers/wgl/stw_context.c
index 1f11b64..663d8b8 100644
--- a/src/gallium/state_trackers/wgl/stw_context.c
+++ b/src/gallium/state_trackers/wgl/stw_context.c
@@ -27,12 +27,13 @@
 
 #include 
 
-#include "main/mtypes.h"
-#include "main/context.h"
 #include "pipe/p_compiler.h"
 #include "pipe/p_context.h"
+#include "state_tracker/st_api.h"
+
+/* for _mesa_share_state */
 #include "state_tracker/st_context.h"
-#include "state_tracker/st_public.h"
+#include "main/context.h"
 
 #include "stw_icd.h"
 #include "stw_device.h"
@@ -44,25 +45,13 @@
 
 
 static INLINE struct stw_context *
-stw_context(GLcontext *glctx)
-{
-   if(!glctx)
-  return NULL;
-   assert(glctx->DriverCtx);
-   return (struct stw_context *)glctx->DriverCtx;
-}
-
-static INLINE struct stw_context *
 stw_current_context(void)
 {
-   /* We must check if multiple threads are being used or GET_CURRENT_CONTEXT 
-* might return the current context of the thread first seen. */
-   _glapi_check_multithread();
+   struct st_context_iface *st;
 
-   {
-  GET_CURRENT_CONTEXT( glctx );
-  return stw_context(glctx);
-   }
+   st = (stw_dev) ? stw_dev->stapi->get_current(stw_dev->stapi) : NULL;
+
+   return (struct stw_context *) ((st) ? st->st_manager_private : NULL);
 }
 
 BOOL APIENTRY
@@ -114,7 +103,11 @@ DrvShareLists(
ctx2 = stw_lookup_context_locked( dhglrc2 );
 
if (ctx1 && ctx2) {
-  ret = _mesa_share_state(ctx2->st->ctx, ctx1->st->ctx);
+  struct st_context *st1, *st2;
+
+  st1 = (struct st_context *) ctx1->st;
+  st2 = (struct st_context *) ctx2->st;
+  ret = _mesa_share_state(st2->ctx, st1->ctx);
}
 
pipe_mutex_unlock( stw_dev->ctx_mutex );
@@ -122,20 +115,6 @@ DrvShareLists(
return ret;
 }
 
-static void
-stw_viewport(GLcontext * glctx, GLint x, GLint y,
- GLsizei width, GLsizei height)
-{
-   struct stw_context *ctx = (struct stw_context *)glctx->DriverCtx;
-   struct stw_framebuffer *fb;
-   
-   fb = stw_framebuffer_from_hdc( ctx->hdc );
-   if(fb) {
-  stw_framebuffer_update(fb);
-  stw_framebuffer_release(fb);
-   }
-}
-
 DHGLRC APIENTRY
 DrvCreateContext(
HDC hdc )
@@ -150,9 +129,7 @@ DrvCreateLayerContext(
 {
int iPixelFormat;
const struct stw_pixelformat_info *pfi;
-   GLvisual visual;
struct stw_context *ctx = NULL;
-   struct pipe_context *pipe = NULL;

if(!stw_dev)
   return 0;
@@ -165,7 +142,6 @@ DrvCreateLayerContext(
   return 0;

pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
-   stw_pixelformat_visual(&visual, pfi);

ctx = CALLOC_STRUCT( stw_context );
if (ctx == NULL)
@@ -174,18 +150,12 @@ DrvCreateLayerContext(
ctx->hdc = hdc;
ctx->iPixelFormat = iPixelFormat;
 
-   /* priv == hdc, pass to stw_flush_frontbuffer as context_private
-*/
-   pipe = stw_dev->screen->context_create( stw_dev->screen, hdc );
-   if (pipe == NULL) 
-  goto no_pipe;
-
-   ctx->st = st_create_context( pipe, &visual, NULL );
+   ctx->st = stw_dev->stapi->create_context(stw_dev->stapi,
+ stw_dev->smapi, &pfi->stvis, NULL);
if (ctx->st == NULL) 
   goto no_st_ctx;
 
-   ctx->st->ctx->DriverCtx = ctx;
-   ctx->st->ctx->Driver.Viewport = stw_viewport;
+   ctx->st->st_manager_private = (void *) ctx;
 

Mesa (master): stw: Fix minor st_api migration glitches.

2010-04-11 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 1dc8e08e84c6b014622e00090eb2d7301355faf6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1dc8e08e84c6b014622e00090eb2d7301355faf6

Author: José Fonseca 
Date:   Sun Apr 11 17:58:17 2010 +0900

stw: Fix minor st_api migration glitches.

---

 src/gallium/state_trackers/wgl/stw_context.c |2 +-
 src/gallium/state_trackers/wgl/stw_st.c  |6 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/wgl/stw_context.c 
b/src/gallium/state_trackers/wgl/stw_context.c
index 663d8b8..0fb7cd8 100644
--- a/src/gallium/state_trackers/wgl/stw_context.c
+++ b/src/gallium/state_trackers/wgl/stw_context.c
@@ -320,7 +320,7 @@ stw_make_current(
if (!stw_dev->stapi->make_current(stw_dev->stapi, ctx->st, fb->stfb, 
fb->stfb))
   goto fail;
 
-   stw_framebuffer_reference(&curctx->current_framebuffer, fb);
+   stw_framebuffer_reference(&ctx->current_framebuffer, fb);
 
 success:
assert(fb);
diff --git a/src/gallium/state_trackers/wgl/stw_st.c 
b/src/gallium/state_trackers/wgl/stw_st.c
index 6c71f2a..1decc62 100644
--- a/src/gallium/state_trackers/wgl/stw_st.c
+++ b/src/gallium/state_trackers/wgl/stw_st.c
@@ -65,6 +65,10 @@ stw_st_framebuffer_validate_locked(struct 
st_framebuffer_iface *stfb,
struct pipe_texture templ;
unsigned i;
 
+   /* remove outdated surface */
+   pipe_surface_reference(&stwfb->front_surface, NULL);
+   pipe_surface_reference(&stwfb->back_surface, NULL);
+
/* remove outdated textures */
if (stwfb->texture_width != width || stwfb->texture_height != height) {
   for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
@@ -137,7 +141,7 @@ stw_st_framebuffer_validate(struct st_framebuffer_iface 
*stfb,
 
if (stwfb->fb->must_resize || (statt_mask & ~stwfb->texture_mask)) {
   stw_st_framebuffer_validate_locked(&stwfb->base,
-statt_mask, stwfb->fb->width, stwfb->fb->height);
+stwfb->fb->width, stwfb->fb->height, statt_mask);
   stwfb->fb->must_resize = FALSE;
}
 

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


Mesa (master): llvmpipe: pipe_target needs now 3 bits to be represented.

2010-04-11 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 5a549d8b48c068040a47e845e6f7d069ec42bf7d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5a549d8b48c068040a47e845e6f7d069ec42bf7d

Author: José Fonseca 
Date:   Mon Apr 12 15:02:22 2010 +0900

llvmpipe: pipe_target needs now 3 bits to be represented.

---

 src/gallium/auxiliary/gallivm/lp_bld_sample.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h 
b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
index fcbf084..94ebe08 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
@@ -55,7 +55,7 @@ struct lp_sampler_static_state
 {
/* pipe_texture's state */
enum pipe_format format;
-   unsigned target:2;
+   unsigned target:3;
unsigned pot_width:1;
unsigned pot_height:1;
unsigned pot_depth:1;

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


Mesa (master): stw: Update for pipe_resource interface changes.

2010-04-11 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 0bddb58d2f8dc07500d0b063608d995628dbe363
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0bddb58d2f8dc07500d0b063608d995628dbe363

Author: José Fonseca 
Date:   Sun Apr 11 18:16:39 2010 +0900

stw: Update for pipe_resource interface changes.

---

 src/gallium/state_trackers/wgl/stw_st.c |   32 --
 1 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/src/gallium/state_trackers/wgl/stw_st.c 
b/src/gallium/state_trackers/wgl/stw_st.c
index 1decc62..f4ea61e 100644
--- a/src/gallium/state_trackers/wgl/stw_st.c
+++ b/src/gallium/state_trackers/wgl/stw_st.c
@@ -40,7 +40,7 @@ struct stw_st_framebuffer {
struct stw_framebuffer *fb;
struct st_visual stvis;
 
-   struct pipe_texture *textures[ST_ATTACHMENT_COUNT];
+   struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
unsigned texture_width, texture_height;
unsigned texture_mask;
 
@@ -62,7 +62,7 @@ stw_st_framebuffer_validate_locked(struct 
st_framebuffer_iface *stfb,
unsigned mask)
 {
struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb);
-   struct pipe_texture templ;
+   struct pipe_resource templ;
unsigned i;
 
/* remove outdated surface */
@@ -72,7 +72,7 @@ stw_st_framebuffer_validate_locked(struct 
st_framebuffer_iface *stfb,
/* remove outdated textures */
if (stwfb->texture_width != width || stwfb->texture_height != height) {
   for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
- pipe_texture_reference(&stwfb->textures[i], NULL);
+ pipe_resource_reference(&stwfb->textures[i], NULL);
}
 
memset(&templ, 0, sizeof(templ));
@@ -84,7 +84,7 @@ stw_st_framebuffer_validate_locked(struct 
st_framebuffer_iface *stfb,
 
for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
   enum pipe_format format;
-  unsigned tex_usage;
+  unsigned bind;
 
   /* the texture already exists or not requested */
   if (stwfb->textures[i] || !(mask & (1 << i))) {
@@ -98,12 +98,12 @@ stw_st_framebuffer_validate_locked(struct 
st_framebuffer_iface *stfb,
   case ST_ATTACHMENT_FRONT_LEFT:
   case ST_ATTACHMENT_BACK_LEFT:
  format = stwfb->stvis.color_format;
- tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ bind = PIPE_BIND_DISPLAY_TARGET |
+PIPE_BIND_RENDER_TARGET;
  break;
   case ST_ATTACHMENT_DEPTH_STENCIL:
  format = stwfb->stvis.depth_stencil_format;
- tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+ bind = PIPE_BIND_DEPTH_STENCIL;
  break;
   default:
  format = PIPE_FORMAT_NONE;
@@ -112,10 +112,10 @@ stw_st_framebuffer_validate_locked(struct 
st_framebuffer_iface *stfb,
 
   if (format != PIPE_FORMAT_NONE) {
  templ.format = format;
- templ.tex_usage = tex_usage;
+ templ.bind = bind;
 
  stwfb->textures[i] =
-stw_dev->screen->texture_create(stw_dev->screen, &templ);
+stw_dev->screen->resource_create(stw_dev->screen, &templ);
   }
}
 
@@ -128,7 +128,7 @@ static boolean
 stw_st_framebuffer_validate(struct st_framebuffer_iface *stfb,
 const enum st_attachment_type *statts,
 unsigned count,
-struct pipe_texture **out)
+struct pipe_resource **out)
 {
struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb);
unsigned statt_mask, i;
@@ -147,7 +147,7 @@ stw_st_framebuffer_validate(struct st_framebuffer_iface 
*stfb,
 
for (i = 0; i < count; i++) {
   out[i] = NULL;
-  pipe_texture_reference(&out[i], stwfb->textures[statts[i]]);
+  pipe_resource_reference(&out[i], stwfb->textures[statts[i]]);
}
 
stw_framebuffer_release(stwfb->fb);
@@ -160,7 +160,7 @@ get_present_surface_locked(struct st_framebuffer_iface 
*stfb,
enum st_attachment_type statt)
 {
struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb);
-   struct pipe_texture *ptex;
+   struct pipe_resource *ptex;
struct pipe_surface *psurf, **cache;

ptex = stwfb->textures[statt];
@@ -183,7 +183,9 @@ get_present_surface_locked(struct st_framebuffer_iface 
*stfb,
 
if (!*cache) {
   *cache = stw_dev->screen->get_tex_surface(stw_dev->screen,
-ptex, 0, 0, 0, PIPE_BUFFER_USAGE_CPU_READ);
+ptex, 0, 0, 0,
+PIPE_BIND_DISPLAY_TARGET |
+PIPE_BIND_RENDER_TARGET);
}
 
if (psurf != *cache)
@@ -257,7 +259,7 @@ stw_st_destroy_framebuffer_locked(struct 
st_framebuffer_iface *stfb)
pipe_surface_reference(&stwfb->back_surface, NULL);
 
for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
-  pipe_texture_reference(&stwfb->textures[i], NULL);
+  pipe_resource_reference(&stwfb->textures[i], NULL);
 
FREE(stwfb);
 }
@@ -270,7 +272,7 @@ stw_st_swap_framebuffer_locked(struct st_f

Mesa (master): trace: Fix several regressions introduced by recent interface changes.

2010-04-11 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: b77583203e44a8937577bf3b813dc66cea1a2005
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b77583203e44a8937577bf3b813dc66cea1a2005

Author: José Fonseca 
Date:   Mon Apr 12 15:03:25 2010 +0900

trace: Fix several regressions introduced by recent interface changes.

---

 src/gallium/drivers/trace/tr_context.c|  121 
 src/gallium/drivers/trace/tr_dump.c   |9 ++-
 src/gallium/drivers/trace/tr_dump.h   |   10 ++-
 src/gallium/drivers/trace/tr_dump_state.c |   68 -
 src/gallium/drivers/trace/tr_dump_state.h |8 ++-
 src/gallium/drivers/trace/tr_screen.c |2 +-
 6 files changed, 142 insertions(+), 76 deletions(-)

diff --git a/src/gallium/drivers/trace/tr_context.c 
b/src/gallium/drivers/trace/tr_context.c
index dd0fd8e..9f92b44 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -1003,27 +1003,34 @@ trace_create_sampler_view(struct pipe_context *_pipe,
struct trace_resource *tr_tex = trace_resource(_resource);
struct pipe_context *pipe = tr_ctx->pipe;
struct pipe_resource *texture = tr_tex->resource;
-   struct trace_sampler_view *result = CALLOC_STRUCT(trace_sampler_view);
+   struct pipe_sampler_view *result;
+   struct trace_sampler_view *tr_view;
 
trace_dump_call_begin("pipe_context", "create_sampler_view");
 
trace_dump_arg(ptr, pipe);
trace_dump_arg(ptr, texture);
-   trace_dump_arg(ptr, templ);
-
-   result->sampler_view = pipe->create_sampler_view(pipe, texture, templ);
+   trace_dump_arg(sampler_view_template, templ);
 
-   result->base = *templ;
-   result->base.reference.count = 1;
-   result->base.texture = NULL;
-   pipe_resource_reference(&result->base.texture, _resource);
-   result->base.context = _pipe;
+   result = pipe->create_sampler_view(pipe, texture, templ);
 
trace_dump_ret(ptr, result);
 
trace_dump_call_end();
 
-   return &result->base;
+   /*
+* Wrap pipe_sampler_view
+*/
+   tr_view = CALLOC_STRUCT(trace_sampler_view);
+   tr_view->base = *templ;
+   tr_view->base.reference.count = 1;
+   tr_view->base.texture = NULL;
+   pipe_resource_reference(&tr_view->base.texture, _resource);
+   tr_view->base.context = _pipe;
+   tr_view->sampler_view = result;
+   result = &tr_view->base;
+
+   return result;
 }
 
 
@@ -1316,26 +1323,13 @@ trace_context_get_transfer(struct pipe_context 
*_context,
 
assert(texture->screen == context->screen);
 
-   trace_dump_call_begin("pipe_context", "get_transfer");
-
-   trace_dump_arg(ptr, context);
-   trace_dump_arg(ptr, texture);
-   trace_dump_arg(uint, sr.face);
-   trace_dump_arg(uint, sr.level);
-   trace_dump_arg(uint, usage);
-   trace_dump_arg(uint, box->x);
-   trace_dump_arg(uint, box->y);
-   trace_dump_arg(uint, box->z);
-   trace_dump_arg(uint, box->width);
-   trace_dump_arg(uint, box->height);
-   trace_dump_arg(uint, box->depth);
+   /*
+* Map and transfers can't be serialized so we convert all write transfers
+* to transfer_inline_write and ignore read transfers.
+*/
 
result = context->get_transfer(context, texture, sr, usage, box);
 
-   trace_dump_ret(ptr, result);
-
-   trace_dump_call_end();
-
if (result)
   result = trace_transfer_create(tr_context, tr_tex, result);
 
@@ -1349,15 +1343,6 @@ trace_context_transfer_destroy(struct pipe_context 
*_context,
 {
struct trace_context *tr_context = trace_context(_context);
struct trace_transfer *tr_trans = trace_transfer(_transfer);
-   struct pipe_context *context = tr_context->pipe;
-   struct pipe_transfer *transfer = tr_trans->transfer;
-
-   trace_dump_call_begin("pipe_context", "transfer_destroy");
-
-   trace_dump_arg(ptr, context);
-   trace_dump_arg(ptr, transfer);
-
-   trace_dump_call_end();
 
trace_transfer_destroy(tr_context, tr_trans);
 }
@@ -1399,12 +1384,7 @@ trace_context_transfer_flush_region( struct pipe_context 
*_context,
 
trace_dump_arg(ptr, context);
trace_dump_arg(ptr, transfer);
-   trace_dump_arg(uint, box->x);
-   trace_dump_arg(uint, box->y);
-   trace_dump_arg(uint, box->z);
-   trace_dump_arg(uint, box->width);
-   trace_dump_arg(uint, box->height);
-   trace_dump_arg(uint, box->depth);
+   trace_dump_arg(box, box);
trace_dump_call_end();
 
context->transfer_flush_region(context,
@@ -1422,27 +1402,35 @@ trace_context_transfer_unmap(struct pipe_context 
*_context,
struct pipe_transfer *transfer = tr_trans->transfer;
 
if(tr_trans->map) {
-  trace_dump_call_begin("pipe_context", "transfer_write");
+  /*
+   * Fake a transfer_inline_write
+   */
 
-  trace_dump_arg(ptr, context);
+  struct pipe_resource *resource = transfer->resource;
+  struct pipe_subresource sr = transfer->sr;
+  unsigned usage = transfer->usage;
+  const struct pipe_box *box = &transfer->box;
+  unsigned stride = transfer->stride;
+  unsigned slice_stride = transfer->slice_stride;
 

Mesa (master): st/python: Fix regressions.

2010-04-11 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: c48f21ea7cb9634c1865514f069b8c0993cb5daf
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c48f21ea7cb9634c1865514f069b8c0993cb5daf

Author: José Fonseca 
Date:   Mon Apr 12 15:04:16 2010 +0900

st/python: Fix regressions.

---

 src/gallium/state_trackers/python/p_context.i |  109 +
 src/gallium/state_trackers/python/p_device.i  |   17 ++--
 src/gallium/state_trackers/python/p_texture.i |   39 -
 3 files changed, 117 insertions(+), 48 deletions(-)

diff --git a/src/gallium/state_trackers/python/p_context.i 
b/src/gallium/state_trackers/python/p_context.i
index 882219f..13c8d1a 100644
--- a/src/gallium/state_trackers/python/p_context.i
+++ b/src/gallium/state_trackers/python/p_context.i
@@ -127,6 +127,45 @@ struct st_context {
   $self->gs = gs;
}
 
+   struct pipe_sampler_view *
+   create_sampler_view(struct pipe_resource *texture,
+   enum pipe_format format = PIPE_FORMAT_NONE,
+   unsigned first_level = 0,
+   unsigned last_level = ~0,
+   unsigned swizzle_r = 0,
+   unsigned swizzle_g = 1,
+   unsigned swizzle_b = 2,
+   unsigned swizzle_a = 3)
+   {
+  struct pipe_context *pipe = $self->pipe;
+  struct pipe_sampler_view templat;
+
+  memset(&templat, 0, sizeof templat);
+  if (format == PIPE_FORMAT_NONE) {
+ templat.format = texture->format;
+  } else {
+ templat.format = format;
+  }
+  templat.last_level = MIN2(last_level, texture->last_level);
+  templat.first_level = first_level;
+  templat.last_level = last_level;
+  templat.swizzle_r = swizzle_r;
+  templat.swizzle_g = swizzle_g;
+  templat.swizzle_b = swizzle_b;
+  templat.swizzle_a = swizzle_a;
+
+  return pipe->create_sampler_view(pipe, texture, &templat);
+   }
+
+   void
+   sampler_view_destroy(struct pipe_context *ctx,
+struct pipe_sampler_view *view)
+   {
+  struct pipe_context *pipe = $self->pipe;
+
+  pipe->sampler_view_destroy(pipe, view);
+   }
+
/*
 * Parameter-like state (or properties)
 */
@@ -167,6 +206,26 @@ struct st_context {
   cso_set_viewport($self->cso, state);
}
 
+   void set_fragment_sampler_view(unsigned index,
+  struct pipe_sampler_view *view)
+   {
+  pipe_sampler_view_reference(&$self->fragment_sampler_views[index], view);
+
+  $self->pipe->set_fragment_sampler_views($self->pipe,
+  PIPE_MAX_SAMPLERS,
+  $self->fragment_sampler_views);
+   }
+
+   void set_vertex_sampler_view(unsigned index,
+struct pipe_sampler_view *view)
+   {
+  pipe_sampler_view_reference(&$self->vertex_sampler_views[index], view);
+
+  $self->pipe->set_vertex_sampler_views($self->pipe,
+PIPE_MAX_VERTEX_SAMPLERS,
+$self->vertex_sampler_views);
+   }
+
void set_fragment_sampler_texture(unsigned index,
  struct pipe_resource *texture) {
   struct pipe_sampler_view templ;
@@ -643,4 +702,54 @@ error1:
   return n;
}
 
+   %cstring_input_binary(const char *STRING, unsigned LENGTH);
+   void
+   transfer_inline_write(struct pipe_resource *resource,
+ struct pipe_subresource *sr,
+ unsigned usage,
+ const struct pipe_box *box,
+ const char *STRING, unsigned LENGTH,
+ unsigned stride,
+ unsigned slice_stride)
+   {
+  struct pipe_context *pipe = $self->pipe;
+
+  pipe->transfer_inline_write(pipe, resource, *sr, usage, box, STRING, 
stride, slice_stride);
+   }
+
+   %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1));
+   void buffer_read(struct pipe_resource *buffer,
+char **STRING, int *LENGTH)
+   {
+  struct pipe_context *pipe = $self->pipe;
+
+  assert(buffer->target == PIPE_BUFFER);
+
+  *LENGTH = buffer->width0;
+  *STRING = (char *) malloc(buffer->width0);
+  if(!*STRING)
+ return;
+
+  pipe_buffer_read(pipe, buffer, 0, buffer->width0, *STRING);
+   }
+
+   void buffer_write(struct pipe_resource *buffer,
+ const char *STRING, unsigned LENGTH, unsigned offset = 0)
+   {
+  struct pipe_context *pipe = $self->pipe;
+
+  assert(buffer->target == PIPE_BUFFER);
+
+  if(offset > buffer->width0)
+ SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer 
size");
+
+  if(offset + LENGTH > buffer->width0)
+ SWIG_exception(SWIG_ValueError, "data length must fit inside the 
buffer");
+
+  pipe_buffer_write(pipe, buffer, offset,

Mesa (master): progs/gallium/raw: Update symbols.

2010-04-11 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: cd70b6bd9ea8bfc4342f45340a1fedfaed81257f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd70b6bd9ea8bfc4342f45340a1fedfaed81257f

Author: José Fonseca 
Date:   Mon Apr 12 15:09:18 2010 +0900

progs/gallium/raw: Update symbols.

Untested -- just the same changes done to progs/gallium/python.

---

 progs/gallium/raw/clear.c|   10 +-
 progs/gallium/trivial/quad-tex.c |8 
 progs/gallium/trivial/tri.c  |4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/progs/gallium/raw/clear.c b/progs/gallium/raw/clear.c
index 5ef5254..706e3be 100644
--- a/progs/gallium/raw/clear.c
+++ b/progs/gallium/raw/clear.c
@@ -56,17 +56,17 @@ int main( int argc, char *argv[] )
templat.depth0 = 1;
templat.last_level = 0;
templat.nr_samples = 1;
-   templat.tex_usage = (PIPE_TEXTURE_USAGE_RENDER_TARGET |
-PIPE_TEXTURE_USAGE_DISPLAY_TARGET);
+   templat.bind = (PIPE_BIND_RENDER_TARGET |
+PIPE_BIND_DISPLAY_TARGET);

-   tex = screen->texture_create(screen,
+   tex = screen->resource_create(screen,
 &templat);
if (tex == NULL)
   exit(4);
 
surf = screen->get_tex_surface(screen, tex, 0, 0, 0,
-  PIPE_TEXTURE_USAGE_RENDER_TARGET |
-  PIPE_TEXTURE_USAGE_DISPLAY_TARGET);
+  PIPE_BIND_RENDER_TARGET |
+  PIPE_BIND_DISPLAY_TARGET);
if (surf == NULL)
   exit(5);
 
diff --git a/progs/gallium/trivial/quad-tex.c b/progs/gallium/trivial/quad-tex.c
index 553f558..7ad157c 100644
--- a/progs/gallium/trivial/quad-tex.c
+++ b/progs/gallium/trivial/quad-tex.c
@@ -146,9 +146,9 @@ static void init_prog(struct program *p)
tmplt.height0 = HEIGHT;
tmplt.depth0 = 1;
tmplt.last_level = 0;
-   tmplt.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+   tmplt.bind = PIPE_BIND_RENDER_TARGET;
 
-   p->target = p->screen->texture_create(p->screen, &tmplt);
+   p->target = p->screen->resource_create(p->screen, &tmplt);
}
 
/* sampler texture */
@@ -165,9 +165,9 @@ static void init_prog(struct program *p)
t_tmplt.height0 = 2;
t_tmplt.depth0 = 1;
t_tmplt.last_level = 0;
-   t_tmplt.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+   t_tmplt.bind = PIPE_BIND_RENDER_TARGET;
 
-   p->tex = p->screen->texture_create(p->screen, &t_tmplt);
+   p->tex = p->screen->resource_create(p->screen, &t_tmplt);
 
t = p->pipe->get_tex_transfer(p->pipe, p->tex,
  0, 0, 0, /* face, level, zslice */
diff --git a/progs/gallium/trivial/tri.c b/progs/gallium/trivial/tri.c
index cae1bdb..6286aef 100644
--- a/progs/gallium/trivial/tri.c
+++ b/progs/gallium/trivial/tri.c
@@ -137,9 +137,9 @@ static void init_prog(struct program *p)
tmplt.height0 = HEIGHT;
tmplt.depth0 = 1;
tmplt.last_level = 0;
-   tmplt.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+   tmplt.bind = PIPE_BIND_RENDER_TARGET;
 
-   p->target = p->screen->texture_create(p->screen, &tmplt);
+   p->target = p->screen->resource_create(p->screen, &tmplt);
}
 
/* disabled blending/masking */

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


Mesa (master): llvmpipe: Respect pipe_sampler_view::format.

2010-04-11 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: d67e3487ac4c678892d0aea535cacfd5f1d86a27
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d67e3487ac4c678892d0aea535cacfd5f1d86a27

Author: José Fonseca 
Date:   Mon Apr 12 15:16:01 2010 +0900

llvmpipe: Respect pipe_sampler_view::format.

---

 src/gallium/auxiliary/gallivm/lp_bld_sample.c |   10 --
 src/gallium/auxiliary/gallivm/lp_bld_sample.h |3 ++-
 src/gallium/drivers/llvmpipe/lp_state_fs.c|2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c 
b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
index 4004741..eb75b9b 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
@@ -51,9 +51,11 @@
  */
 void
 lp_sampler_static_state(struct lp_sampler_static_state *state,
-const struct pipe_resource *texture,
+const struct pipe_sampler_view *view,
 const struct pipe_sampler_state *sampler)
 {
+   const struct pipe_resource *texture = view->texture;
+
memset(state, 0, sizeof *state);
 
if(!texture)
@@ -74,7 +76,7 @@ lp_sampler_static_state(struct lp_sampler_static_state *state,
 * regarding 1D/2D/3D/CUBE textures, wrap modes, etc.
 */
 
-   state->format= texture->format;
+   state->format= view->format;
state->target= texture->target;
state->pot_width = util_is_pot(texture->width0);
state->pot_height= util_is_pot(texture->height0);
@@ -104,6 +106,10 @@ lp_sampler_static_state(struct lp_sampler_static_state 
*state,
state->border_color[1]   = sampler->border_color[1];
state->border_color[2]   = sampler->border_color[2];
state->border_color[3]   = sampler->border_color[3];
+
+   /*
+* FIXME: Handle the remainder of pipe_sampler_view.
+*/
 }
 
 
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h 
b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
index 94ebe08..8c1af95 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
@@ -39,6 +39,7 @@
 #include "gallivm/lp_bld.h"
 
 struct pipe_resource;
+struct pipe_sampler_view;
 struct pipe_sampler_state;
 struct util_format_description;
 struct lp_type;
@@ -130,7 +131,7 @@ struct lp_sampler_dynamic_state
  */
 void
 lp_sampler_static_state(struct lp_sampler_static_state *state,
-const struct pipe_resource *texture,
+const struct pipe_sampler_view *view,
 const struct pipe_sampler_state *sampler);
 
 
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index c57b4a4..e82364d 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -1130,7 +1130,7 @@ make_variant_key(struct llvmpipe_context *lp,
 
for(i = 0; i < PIPE_MAX_SAMPLERS; ++i)
   if(shader->info.file_mask[TGSI_FILE_SAMPLER] & (1 << i))
- lp_sampler_static_state(&key->sampler[i], 
lp->fragment_sampler_views[i]->texture, lp->sampler[i]);
+ lp_sampler_static_state(&key->sampler[i], 
lp->fragment_sampler_views[i], lp->sampler[i]);
 }
 
 

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


Mesa (master): progs/gallium/python: Try to fix most regressions.

2010-04-11 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 19211bb5b8fa406fde294ec84f814e3b7881c474
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=19211bb5b8fa406fde294ec84f814e3b7881c474

Author: José Fonseca 
Date:   Mon Apr 12 15:08:05 2010 +0900

progs/gallium/python: Try to fix most regressions.

Not enough for retrace to work again though.

---

 progs/gallium/python/retrace/interpreter.py|  184 ---
 progs/gallium/python/samples/gs.py |8 +-
 progs/gallium/python/samples/tri.py|8 +-
 .../regress/fragment-shader/fragment-shader.py |4 +-
 .../tests/regress/vertex-shader/vertex-shader.py   |4 +-
 progs/gallium/python/tests/surface_copy.py |   14 +-
 progs/gallium/python/tests/texture_blit.py |   28 ++--
 progs/gallium/python/tests/texture_render.py   |   16 +-
 progs/gallium/python/tests/texture_transfer.py |8 +-
 9 files changed, 123 insertions(+), 151 deletions(-)

diff --git a/progs/gallium/python/retrace/interpreter.py 
b/progs/gallium/python/retrace/interpreter.py
index 1a96181..60253cf 100755
--- a/progs/gallium/python/retrace/interpreter.py
+++ b/progs/gallium/python/retrace/interpreter.py
@@ -109,6 +109,8 @@ struct_factories = {
 "pipe_vertex_element": gallium.VertexElement,
 "pipe_viewport_state": gallium.Viewport,
 #"pipe_texture": gallium.Texture,
+'pipe_subresource': gallium.pipe_subresource,
+'pipe_box': gallium.pipe_box,
 }
 
 
@@ -185,14 +187,8 @@ class Global(Object):
 self.interpreter = interpreter
 self.real = real
 
-def pipe_winsys_create(self):
-return Winsys(self.interpreter, gallium.Device())
-
-def pipe_screen_create(self, winsys=None):
-if winsys is None:
-real = gallium.Device()
-else:
-real = winsys.real
+def pipe_screen_create(self):
+real = gallium.Device()
 return Screen(self.interpreter, real)
 
 def pipe_context_create(self, screen):
@@ -200,59 +196,13 @@ class Global(Object):
 return Context(self.interpreter, context)
 
 
-class Winsys(Object):
-
-def __init__(self, interpreter, real):
-self.interpreter = interpreter
-self.real = real
-
-def get_name(self):
-pass
-
-def user_buffer_create(self, data, size):
-# We don't really care to distinguish between user and regular buffers
-buffer = self.real.buffer_create(size, 
- 4, 
- gallium.PIPE_BUFFER_USAGE_CPU_READ |
- gallium.PIPE_BUFFER_USAGE_CPU_WRITE )
-assert size == len(data)
-buffer.write(data)
-return buffer
-
-def buffer_create(self, alignment, usage, size):
-return self.real.buffer_create(size, alignment, usage)
-
-def buffer_destroy(self, buffer):
-pass
-
-def buffer_write(self, buffer, data, size):
-assert size == len(data)
-buffer.write(data)
-
-def fence_finish(self, fence, flags):
-pass
-
-def fence_reference(self, dst, src):
-pass
-
-def flush_frontbuffer(self, surface):
-pass
-
-def surface_alloc(self):
-return None
-
-def surface_release(self, surface):
-pass
-
-
 class Transfer:
 
-def __init__(self, surface, x, y, w, h):
-self.surface = surface
-self.x = x
-self.y = y
-self.w = w
-self.h = h
+def __init__(self, resource, usage, subresource, box):
+self.resource = resource
+self.usage = usage
+self.subresource = subresource
+self.box = box
 
 
 class Screen(Object):
@@ -276,18 +226,18 @@ class Screen(Object):
 context = self.real.context_create()
 return Context(self.interpreter, context)
 
-def is_format_supported(self, format, target, tex_usage, geom_flags):
-return self.real.is_format_supported(format, target, tex_usage, 
geom_flags)
+def is_format_supported(self, format, target, bind, geom_flags):
+return self.real.is_format_supported(format, target, bind, geom_flags)
 
-def texture_create(self, templat):
-return self.real.texture_create(
+def resource_create(self, templat):
+return self.real.resource_create(
 format = templat.format,
 width = templat.width,
 height = templat.height,
 depth = templat.depth,
 last_level = templat.last_level,
 target = templat.target,
-tex_usage = templat.tex_usage,
+bind = templat.bind,
 )
 
 def texture_destroy(self, texture):
@@ -307,37 +257,9 @@ class Screen(Object):
 def tex_surface_release(self, surface):
 pass
 
-def surface_write(self, surface, data, stride, size):
-if surface is None:
-return
-#assert sur

Mesa (master): progs/gallium: Move into src/gallium/tests

2010-04-12 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 6917ef10f20d2c6de92e5432b9483d9648d8b0c0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6917ef10f20d2c6de92e5432b9483d9648d8b0c0

Author: José Fonseca 
Date:   Tue Apr 13 07:05:13 2010 +0900

progs/gallium: Move into src/gallium/tests

Two reasons:
- progs will eventually have its own repository
- it is just to easy to forget updating the
  code for interface changes when it is outside of src

---

 progs/SConscript   |2 --
 src/gallium/SConscript |3 +++
 .../gallium/tests}/python/retrace/README   |0 
 .../gallium/tests}/python/retrace/format.py|0 
 .../gallium/tests}/python/retrace/interpreter.py   |0 
 .../gallium/tests}/python/retrace/model.py |0 
 .../gallium/tests}/python/retrace/parse.py |0 
 .../gallium/tests}/python/retrace/parser.py|0 
 .../gallium/tests}/python/samples/gs.py|0 
 .../gallium/tests}/python/samples/tri.py   |0 
 .../gallium/tests}/python/tests/.gitignore |0 
 .../gallium/tests}/python/tests/base.py|0 
 .../tests/regress/fragment-shader/.gitignore   |0 
 .../tests/regress/fragment-shader/frag-abs.sh  |0 
 .../tests/regress/fragment-shader/frag-add.sh  |0 
 .../tests/regress/fragment-shader/frag-cb-1d.sh|0 
 .../tests/regress/fragment-shader/frag-cb-2d.sh|0 
 .../tests/regress/fragment-shader/frag-dp3.sh  |0 
 .../tests/regress/fragment-shader/frag-dp4.sh  |0 
 .../tests/regress/fragment-shader/frag-dst.sh  |0 
 .../tests/regress/fragment-shader/frag-ex2.sh  |0 
 .../tests/regress/fragment-shader/frag-flr.sh  |0 
 .../tests/regress/fragment-shader/frag-frc.sh  |0 
 .../tests/regress/fragment-shader/frag-lg2.sh  |0 
 .../tests/regress/fragment-shader/frag-lit.sh  |0 
 .../tests/regress/fragment-shader/frag-lrp.sh  |0 
 .../tests/regress/fragment-shader/frag-mad.sh  |0 
 .../tests/regress/fragment-shader/frag-max.sh  |0 
 .../tests/regress/fragment-shader/frag-min.sh  |0 
 .../tests/regress/fragment-shader/frag-mov.sh  |0 
 .../tests/regress/fragment-shader/frag-mul.sh  |0 
 .../tests/regress/fragment-shader/frag-rcp.sh  |0 
 .../tests/regress/fragment-shader/frag-rsq.sh  |0 
 .../tests/regress/fragment-shader/frag-sge.sh  |0 
 .../tests/regress/fragment-shader/frag-slt.sh  |0 
 .../regress/fragment-shader/frag-srcmod-abs.sh |0 
 .../regress/fragment-shader/frag-srcmod-absneg.sh  |0 
 .../regress/fragment-shader/frag-srcmod-neg.sh |0 
 .../regress/fragment-shader/frag-srcmod-swz.sh |0 
 .../tests/regress/fragment-shader/frag-sub.sh  |0 
 .../tests/regress/fragment-shader/frag-xpd.sh  |0 
 .../regress/fragment-shader/fragment-shader.py |0 
 .../python/tests/regress/vertex-shader/.gitignore  |0 
 .../python/tests/regress/vertex-shader/vert-abs.sh |0 
 .../python/tests/regress/vertex-shader/vert-add.sh |0 
 .../python/tests/regress/vertex-shader/vert-arl.sh |0 
 .../python/tests/regress/vertex-shader/vert-arr.sh |0 
 .../tests/regress/vertex-shader/vert-cb-1d.sh  |0 
 .../tests/regress/vertex-shader/vert-cb-2d.sh  |0 
 .../python/tests/regress/vertex-shader/vert-dp3.sh |0 
 .../python/tests/regress/vertex-shader/vert-dp4.sh |0 
 .../python/tests/regress/vertex-shader/vert-dst.sh |0 
 .../python/tests/regress/vertex-shader/vert-ex2.sh |0 
 .../python/tests/regress/vertex-shader/vert-flr.sh |0 
 .../python/tests/regress/vertex-shader/vert-frc.sh |0 
 .../python/tests/regress/vertex-shader/vert-lg2.sh |0 
 .../python/tests/regress/vertex-shader/vert-lit.sh |0 
 .../python/tests/regress/vertex-shader/vert-lrp.sh |0 
 .../python/tests/regress/vertex-shader/vert-mad.sh |0 
 .../python/tests/regress/vertex-shader/vert-max.sh |0 
 .../python/tests/regress/vertex-shader/vert-min.sh |0 
 .../python/tests/regress/vertex-shader/vert-mov.sh |0 
 .../python/tests/regress/vertex-shader/vert-mul.sh |0 
 .../python/tests/regress/vertex-shader/vert-rcp.sh |0 
 .../python/tests/regress/vertex-shader/vert-rsq.sh |0 
 .../python/tests/regress/vertex-shader/vert-sge.sh |0 
 .../python/tests/regress/vertex-shader/vert-slt.sh |0 
 .../tests/regress/vertex-shader/vert-srcmod-abs.sh |0 
 .../regress/vertex-shader/vert-srcmod-absneg.sh|0 
 .../tests/regress/vertex-shader/vert-srcmod-neg.sh |0 
 .../tests/regress/vertex-shader/vert-srcmod-swz.sh |0 
 .../python/tests/regress/vertex-shader/vert-sub.sh |0 
 .../python/tests/regress/vertex-shader/vert-xpd.sh |0 
 .../tests/regress/vertex-shader/vertex-shader.py   |0 
 .../gallium/tests}/python/tests/surface_copy.py|0 
 .../gallium/tests}/python/tests/texture_blit

Mesa (master): scons: Fix exception when llvm-config is not present.

2010-04-13 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: cd4e5879ebd4fe71c5e95d83cdf4a2ebd2fd1e06
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd4e5879ebd4fe71c5e95d83cdf4a2ebd2fd1e06

Author: José Fonseca 
Date:   Tue Apr 13 19:40:48 2010 +0900

scons: Fix exception when llvm-config is not present.

---

 common.py |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/common.py b/common.py
index 8372176..742dabf 100644
--- a/common.py
+++ b/common.py
@@ -34,10 +34,15 @@ else:
default_machine = _platform.machine()
 default_machine = _machine_map.get(default_machine, 'generic')
 
-if 'LLVM' in os.environ or subprocess.call(['llvm-config', '--version'], 
stdout=subprocess.PIPE) == 0:
+if 'LLVM' in os.environ:
 default_llvm = 'yes'
 else:
 default_llvm = 'no'
+try:
+if subprocess.call(['llvm-config', '--version'], 
stdout=subprocess.PIPE) == 0:
+default_llvm = 'yes'
+except:
+pass
 
 if default_platform in ('linux', 'freebsd'):
default_dri = 'yes'

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


Mesa (master): retrace: Update for recent interface changes.

2010-04-13 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: c57bac1f13d2bb00d04d8436d2042f0ab02549d4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c57bac1f13d2bb00d04d8436d2042f0ab02549d4

Author: José Fonseca 
Date:   Wed Apr 14 10:22:41 2010 +0900

retrace: Update for recent interface changes.

---

 src/gallium/tests/python/retrace/interpreter.py |   47 ---
 1 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/src/gallium/tests/python/retrace/interpreter.py 
b/src/gallium/tests/python/retrace/interpreter.py
index 60253cf..47538d2 100755
--- a/src/gallium/tests/python/retrace/interpreter.py
+++ b/src/gallium/tests/python/retrace/interpreter.py
@@ -43,7 +43,7 @@ except ImportError:
 return struct.unpack(fmt, buf[offset:offset + size])
 
 
-def make_image(surface, x=None, y=None, w=None, h=None):
+def make_image(ctx, surface, x=None, y=None, w=None, h=None):
 if x is None:
 x = 0
 if y is None:
@@ -52,18 +52,18 @@ def make_image(surface, x=None, y=None, w=None, h=None):
 w = surface.width - x
 if h is None:
 h = surface.height - y
-data = surface.get_tile_rgba8(x, y, surface.width, surface.height)
+data = ctx.surface_read_rgba8(surface, x, y, surface.width, surface.height)
 
 import Image
 outimage = Image.fromstring('RGBA', (w, h), data, "raw", 'RGBA', 0, 1)
 return outimage
 
-def save_image(filename, surface, x=None, y=None, w=None, h=None):
-outimage = make_image(surface, x, y, w, h)
+def save_image(ctx, filename, surface, x=None, y=None, w=None, h=None):
+outimage = make_image(ctx, surface, x, y, w, h)
 outimage.save(filename, "PNG")
 
-def show_image(surface, title, x=None, y=None, w=None, h=None):
-outimage = make_image(surface, x, y, w, h)
+def show_image(ctx, surface, title, x=None, y=None, w=None, h=None):
+outimage = make_image(ctx, surface, x, y, w, h)
 
 import Tkinter as tk
 from PIL import Image, ImageTk
@@ -207,6 +207,10 @@ class Transfer:
 
 class Screen(Object):
 
+def __init__(self, interpreter, real):
+Object.__init__(self, interpreter, real)
+self.context = self.real.context_create()
+
 def destroy(self):
 pass
 
@@ -257,11 +261,12 @@ class Screen(Object):
 def tex_surface_release(self, surface):
 pass
 
-def user_buffer_create(self, data, size, bind):
+def user_buffer_create(self, data, size, usage):
+bind = usage
 # We don't really care to distinguish between user and regular buffers
 buffer = self.real.buffer_create(size, bind)
 assert size == len(data)
-buffer.write(data)
+self.context.buffer_write(buffer, data)
 return buffer
 
 def buffer_create(self, alignment, usage, size):
@@ -547,7 +552,7 @@ class Context(Object):
 def surface_copy(self, dest, destx, desty, src, srcx, srcy, width, height):
 if dest is not None and src is not None:
 if self.interpreter.options.all:
-self.interpreter.present(src, 'surface_copy_src', srcx, srcy, 
width, height)
+self.interpreter.present(self.real, src, 'surface_copy_src', 
srcx, srcy, width, height)
 self.real.surface_copy(dest, destx, desty, src, srcx, srcy, width, 
height)
 if dest in self.cbufs:
 self._set_dirty()
@@ -556,14 +561,10 @@ class Context(Object):
 flags = 0
 self.flush(flags)
 if self.interpreter.options.all:
-self.interpreter.present(dest, 'surface_copy_dest', destx, 
desty, width, height)
+self.interpreter.present(self.real, dest, 'surface_copy_dest', 
destx, desty, width, height)
 
-def is_texture_referenced(self, texture, face, level):
-#return self.real.is_texture_referenced(format, texture, face, level)
-pass
-
-def is_buffer_referenced(self, buf):
-#return self.real.is_buffer_referenced(format, buf)
+def is_resource_referenced(self, texture, face, level):
+#return self.real.is_resource_referenced(format, texture, face, level)
 pass
 
 def buffer_write(self, buffer, data, size, offset=0):
@@ -583,7 +584,7 @@ class Context(Object):
 if transfer and usage & gallium.PIPE_TRANSFER_READ:
 if self.interpreter.options.all:
 surface = texture.get_surface(sr.face, sr.level, box.z)
-self.interpreter.present(transfer.surface, 'transf_read', 
box.x, box.y, box.w, box.h)
+self.interpreter.present(self.real, transfer.surface, 
'transf_read', box.x, box.y, box.w, box.h)
 return transfer
 
 def tex_transfer_destroy(self, transfer):
@@ -597,7 +598,7 @@ class Context(Object):
 if self.interpreter.options.all:
 box = transfer.box
 surface = transfer.resource.get_surface(sr.face, sr.level, box.z)
-self.interpreter.present(transfer.surface, 'transf_write', box.

Mesa (master): trace: Ignore transfer_flush_region too.

2010-04-13 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: d2c5a3093ffc6d1eae2689d603c502ecbdb6edcd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d2c5a3093ffc6d1eae2689d603c502ecbdb6edcd

Author: José Fonseca 
Date:   Wed Apr 14 10:03:22 2010 +0900

trace: Ignore transfer_flush_region too.

---

 src/gallium/drivers/trace/tr_context.c |7 ---
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/trace/tr_context.c 
b/src/gallium/drivers/trace/tr_context.c
index 9f92b44..512acb7 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -1380,13 +1380,6 @@ trace_context_transfer_flush_region( struct pipe_context 
*_context,
struct pipe_context *context = tr_context->pipe;
struct pipe_transfer *transfer = tr_transfer->transfer;
 
-   trace_dump_call_begin("pipe_context", "transfer_flush_region");
-
-   trace_dump_arg(ptr, context);
-   trace_dump_arg(ptr, transfer);
-   trace_dump_arg(box, box);
-   trace_dump_call_end();
-
context->transfer_flush_region(context,
  transfer,
  box);

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


Mesa (master): mesa: Restore comment too.

2010-04-18 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 6aae062bdf285ce9ce861b4d3b777080664518ba
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6aae062bdf285ce9ce861b4d3b777080664518ba

Author: José Fonseca 
Date:   Sat Apr 17 14:25:05 2010 +0200

mesa: Restore comment too.

---

 src/mesa/shader/program_parse.tab.c |2 +-
 src/mesa/shader/program_parse.y |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/shader/program_parse.tab.c 
b/src/mesa/shader/program_parse.tab.c
index 5679b64..e5ef25e 100644
--- a/src/mesa/shader/program_parse.tab.c
+++ b/src/mesa/shader/program_parse.tab.c
@@ -5560,7 +5560,7 @@ make_error_string(const char *fmt, ...)
va_start(args, fmt);
 
/* Call vsnprintf once to determine how large the final string is.  Call it
-* again to do the actual formatting.  from the v_mesa_snprintf manual page:
+* again to do the actual formatting.  from the vsnprintf manual page:
 *
 *Upon successful return, these functions return the number of
 *characters printed  (not including the trailing '\0' used to end
diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y
index d5fb0fa..299e247 100644
--- a/src/mesa/shader/program_parse.y
+++ b/src/mesa/shader/program_parse.y
@@ -2599,7 +2599,7 @@ make_error_string(const char *fmt, ...)
va_start(args, fmt);
 
/* Call vsnprintf once to determine how large the final string is.  Call it
-* again to do the actual formatting.  from the v_mesa_snprintf manual page:
+* again to do the actual formatting.  from the vsnprintf manual page:
 *
 *Upon successful return, these functions return the number of
 *characters printed  (not including the trailing '\0' used to end

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


Mesa (master): retrace: Remove deprecated code.

2010-04-18 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 5c898af8702ae31babe62780302736105386be02
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5c898af8702ae31babe62780302736105386be02

Author: José Fonseca 
Date:   Sat Apr 17 14:35:26 2010 +0200

retrace: Remove deprecated code.

---

 src/gallium/tests/python/retrace/interpreter.py |   10 --
 1 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/src/gallium/tests/python/retrace/interpreter.py 
b/src/gallium/tests/python/retrace/interpreter.py
index 47538d2..506a4c5 100755
--- a/src/gallium/tests/python/retrace/interpreter.py
+++ b/src/gallium/tests/python/retrace/interpreter.py
@@ -590,16 +590,6 @@ class Context(Object):
 def tex_transfer_destroy(self, transfer):
 self.interpreter.unregister_object(transfer)
 
-def transfer_write(self, transfer, data, size):
-if transfer is None:
-return
-self.real.transfer_inline_write(resource, sr, usage, box, data, 
stride, slice_stride)
-self.transfertransfer.surface.put_tile_raw(transfer.x, transfer.y, 
transfer.w, transfer.h, data, transfer.stride)
-if self.interpreter.options.all:
-box = transfer.box
-surface = transfer.resource.get_surface(sr.face, sr.level, box.z)
-self.interpreter.present(self.real, transfer.surface, 
'transf_write', box.x, box.y, box.w, box.h)
-
 def transfer_inline_write(self, resource, sr, usage, box, stride, 
slice_stride, data):
 self.real.transfer_inline_write(resource, sr, usage, box, data, 
stride, slice_stride)
 

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


Mesa (master): st/python: Set the bind flag for the default texture.

2010-04-18 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 4b95c9549db721392bf7a1f5ee820af17694fe38
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4b95c9549db721392bf7a1f5ee820af17694fe38

Author: José Fonseca 
Date:   Sat Apr 17 14:48:19 2010 +0200

st/python: Set the bind flag for the default texture.

---

 src/gallium/state_trackers/python/st_device.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/gallium/state_trackers/python/st_device.c 
b/src/gallium/state_trackers/python/st_device.c
index 135acad..aac28ca 100644
--- a/src/gallium/state_trackers/python/st_device.c
+++ b/src/gallium/state_trackers/python/st_device.c
@@ -243,6 +243,7 @@ st_context_create(struct st_device *st_dev)
   templat.height0 = 1;
   templat.depth0 = 1;
   templat.last_level = 0;
+  templat.bind = PIPE_BIND_SAMPLER_VIEW;

   st_ctx->default_texture = screen->resource_create( screen, &templat );
   if(st_ctx->default_texture) {

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


Mesa (master): trace: Handle transfers with zero strides correctly.

2010-04-18 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 53c3c914a786a4a579532671bd9cb79b41cae78d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=53c3c914a786a4a579532671bd9cb79b41cae78d

Author: José Fonseca 
Date:   Sat Apr 17 15:00:13 2010 +0200

trace: Handle transfers with zero strides correctly.

---

 src/gallium/drivers/trace/tr_dump.c |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/trace/tr_dump.c 
b/src/gallium/drivers/trace/tr_dump.c
index 8ff25fb..51a4ea9 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -478,8 +478,16 @@ void trace_dump_box_bytes(const void *data,
  unsigned stride,
  unsigned slice_stride)
 {
-   size_t size = MAX2(util_format_get_nblocksy(format, box->height) * stride,
-  box->depth * slice_stride);
+   size_t size;
+
+   if (slice_stride)
+  size = box->depth * slice_stride;
+   else if (stride)
+  size = util_format_get_nblocksy(format, box->height) * stride;
+   else {
+  size = util_format_get_nblocksx(format, box->width) * 
util_format_get_blocksize(format);
+   }
+
trace_dump_bytes(data, size);
 }
 

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


Mesa (master): retrace: Fix vertex/index/constant buffer dumping.

2010-04-18 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: d036e9312fcc1f3ee67740ab2ef828f7b47367d2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d036e9312fcc1f3ee67740ab2ef828f7b47367d2

Author: José Fonseca 
Date:   Sat Apr 17 15:11:58 2010 +0200

retrace: Fix vertex/index/constant buffer dumping.

---

 src/gallium/tests/python/retrace/interpreter.py |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/gallium/tests/python/retrace/interpreter.py 
b/src/gallium/tests/python/retrace/interpreter.py
index 506a4c5..88b3bbd 100755
--- a/src/gallium/tests/python/retrace/interpreter.py
+++ b/src/gallium/tests/python/retrace/interpreter.py
@@ -385,7 +385,7 @@ class Context(Object):
 if not self.interpreter.verbosity(2):
 return
 
-data = buffer.read()
+data = self.real.buffer_read(buffer)
 format = '4f'
 index = 0
 for offset in range(0, len(data), struct.calcsize(format)):
@@ -486,10 +486,11 @@ class Context(Object):
 gallium.PIPE_FORMAT_R32G32B32A32_FLOAT: '4f',
 gallium.PIPE_FORMAT_A8R8G8B8_UNORM: '4B',
 gallium.PIPE_FORMAT_R8G8B8A8_UNORM: '4B',
+gallium.PIPE_FORMAT_B8G8R8A8_UNORM: '4B',
 gallium.PIPE_FORMAT_R16G16B16_SNORM: '3h',
 }[velem.src_format]
 
-data = vbuf.buffer.read()
+data = self.real.buffer_read(vbuf.buffer)
 values = unpack_from(format, data, offset)
 sys.stdout.write('\t\t{' + ', '.join(map(str, values)) + 
'},\n')
 sys.stdout.write('\t},\n')
@@ -507,7 +508,7 @@ class Context(Object):
 
 assert struct.calcsize(format) == isize
 
-data = ibuf.read()
+data = self.real.buffer_read(ibuf)
 maxindex, minindex = 0, 0x
 
 sys.stdout.write('\t{\n')

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


Mesa (master): draw: Cosmetic cleanups and comments.

2010-04-18 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: b609cfc7c9c38f26e7e6d6f7dd5dd6d38f4ed209
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b609cfc7c9c38f26e7e6d6f7dd5dd6d38f4ed209

Author: José Fonseca 
Date:   Sun Apr 18 09:45:54 2010 +0200

draw: Cosmetic cleanups and comments.

---

 src/gallium/auxiliary/draw/draw_context.c   |6 ++
 src/gallium/auxiliary/draw/draw_pipe.c  |2 +-
 src/gallium/auxiliary/draw/draw_pipe_vbuf.c |2 +-
 src/gallium/auxiliary/draw/draw_vertex.h|4 ++--
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_context.c 
b/src/gallium/auxiliary/draw/draw_context.c
index b6574a9..99f4e6d 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -56,6 +56,12 @@ fail:
 
 boolean draw_init(struct draw_context *draw)
 {
+   /*
+* Note that several functions compute the clipmask of the predefined
+* formats with hardcoded formulas instead of using these. So modifications
+* here must be reflected there too.
+*/
+
ASSIGN_4V( draw->plane[0], -1,  0,  0, 1 );
ASSIGN_4V( draw->plane[1],  1,  0,  0, 1 );
ASSIGN_4V( draw->plane[2],  0, -1,  0, 1 );
diff --git a/src/gallium/auxiliary/draw/draw_pipe.c 
b/src/gallium/auxiliary/draw/draw_pipe.c
index 83dc1a3..b8f57dd 100644
--- a/src/gallium/auxiliary/draw/draw_pipe.c
+++ b/src/gallium/auxiliary/draw/draw_pipe.c
@@ -225,7 +225,7 @@ static void do_triangle( struct draw_context *draw,
 
 
 /**
- * Code to run the pipeline on a fairly arbitary collection of vertices.
+ * Code to run the pipeline on a fairly arbitrary collection of vertices.
  * For drawing indexed primitives.
  *
  * Vertex headers must be pre-initialized with the
diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c 
b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
index 1c7db00..ee2b811 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
@@ -235,7 +235,7 @@ vbuf_start_prim( struct vbuf_stage *vbuf, uint prim )
for (i = 0; i < vbuf->vinfo->num_attribs; i++) {
   unsigned emit_sz = 0;
   unsigned src_buffer = 0;
-  unsigned output_format;
+  enum pipe_format output_format;
   unsigned src_offset = (vbuf->vinfo->attrib[i].src_index * 4 * 
sizeof(float) );
 
   output_format = draw_translate_vinfo_format(vbuf->vinfo->attrib[i].emit);
diff --git a/src/gallium/auxiliary/draw/draw_vertex.h 
b/src/gallium/auxiliary/draw/draw_vertex.h
index ca27237..3af31ff 100644
--- a/src/gallium/auxiliary/draw/draw_vertex.h
+++ b/src/gallium/auxiliary/draw/draw_vertex.h
@@ -142,7 +142,7 @@ void draw_dump_emitted_vertex(const struct vertex_info 
*vinfo,
   const uint8_t *data);
 
 
-static INLINE unsigned draw_translate_vinfo_format(enum attrib_emit emit)
+static INLINE enum pipe_format draw_translate_vinfo_format(enum attrib_emit 
emit)
 {
switch (emit) {
case EMIT_OMIT:
@@ -166,7 +166,7 @@ static INLINE unsigned draw_translate_vinfo_format(enum 
attrib_emit emit)
}
 }
 
-static INLINE unsigned draw_translate_vinfo_size(enum attrib_emit emit)
+static INLINE enum attrib_emit draw_translate_vinfo_size(enum attrib_emit emit)
 {
switch (emit) {
case EMIT_OMIT:

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


Mesa (master): softpipe: Preserve/ check the signal of the number of scanlines in an edge.

2010-04-18 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 4272c01fbfd42833e4e0937bed84e45fe5da52b9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4272c01fbfd42833e4e0937bed84e45fe5da52b9

Author: José Fonseca 
Date:   Sun Apr 18 09:48:55 2010 +0200

softpipe: Preserve/check the signal of the number of scanlines in an edge.

It can become negative in some weird triangles.

---

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

diff --git a/src/gallium/drivers/softpipe/sp_setup.c 
b/src/gallium/drivers/softpipe/sp_setup.c
index 85966bc..e136cb7 100644
--- a/src/gallium/drivers/softpipe/sp_setup.c
+++ b/src/gallium/drivers/softpipe/sp_setup.c
@@ -691,7 +691,7 @@ static void setup_tri_edges( struct setup_context *setup )
 static void subtriangle( struct setup_context *setup,
 struct edge *eleft,
 struct edge *eright,
-unsigned lines )
+int lines )
 {
const struct pipe_scissor_state *cliprect = &setup->softpipe->cliprect;
const int minx = (int) cliprect->minx;
@@ -702,6 +702,7 @@ static void subtriangle( struct setup_context *setup,
int sy = (int)eleft->sy;
 
assert((int)eleft->sy == (int) eright->sy);
+   assert(lines >= 0);
 
/* clip top/bottom */
start_y = sy;

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


Mesa (master): llvmpipe: Emit only the vertex attributes necessary for the FS, and ensure the first one is always position.

2010-04-18 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 4b148bcf5e6cf08fac31cd10b42ac5f5a5f43cd6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4b148bcf5e6cf08fac31cd10b42ac5f5a5f43cd6

Author: José Fonseca 
Date:   Sun Apr 18 10:34:01 2010 +0200

llvmpipe: Emit only the vertex attributes necessary for the FS, and ensure the 
first one is always position.

With this we correctly handle vertex shaders whose output position is not
in index zero.

---

 src/gallium/drivers/llvmpipe/lp_state_derived.c |  135 +++
 1 files changed, 67 insertions(+), 68 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c 
b/src/gallium/drivers/llvmpipe/lp_state_derived.c
index 7778716..113d77a 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_derived.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c
@@ -50,88 +50,87 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe)
 {
const struct lp_fragment_shader *lpfs = llvmpipe->fs;
struct vertex_info *vinfo = &llvmpipe->vertex_info;
-   const uint num = draw_num_shader_outputs(llvmpipe->draw);
+   struct lp_shader_input inputs[1 + PIPE_MAX_SHADER_INPUTS];
+   unsigned vs_index;
uint i;
 
-   /* Tell setup to tell the draw module to simply emit the whole
-* post-xform vertex as-is.
-*
-* Not really sure if this is the best approach.
+   /*
+* Match FS inputs against VS outputs, emitting the necessary attributes.
 */
-   vinfo->num_attribs = 0;
-   for (i = 0; i < num; i++) {
-  draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, i);
-   }
-   draw_compute_vertex_size(vinfo);
-
-
-   lp_setup_set_vertex_info(llvmpipe->setup, vinfo);
 
-/*
-   llvmpipe->psize_slot = draw_find_vs_output(llvmpipe->draw,
-  TGSI_SEMANTIC_PSIZE, 0);
-*/
-
-   /* Now match FS inputs against emitted vertex data.  It's also
-* entirely possible to just have a fixed layout for FS input,
-* determined by the fragment shader itself, and adjust the draw
-* outputs to match that.
-*/
-   {
-  struct lp_shader_input inputs[PIPE_MAX_SHADER_INPUTS];
-
-  for (i = 0; i < lpfs->info.num_inputs; i++) {
+   vinfo->num_attribs = 0;
 
- /* This can be precomputed, except for flatshade:
+   vs_index = draw_find_shader_output(llvmpipe->draw,
+   TGSI_SEMANTIC_POSITION,
+   0);
+
+   draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index);
+
+   for (i = 0; i < lpfs->info.num_inputs; i++) {
+  /*
+   * Search for each input in current vs output:
+   */
+
+  vs_index = draw_find_shader_output(llvmpipe->draw,
+ lpfs->info.input_semantic_name[i],
+ lpfs->info.input_semantic_index[i]);
+
+  /* This can be pre-computed, except for flatshade:
+   */
+  switch (lpfs->info.input_semantic_name[i]) {
+  case TGSI_SEMANTIC_FACE:
+ inputs[i].interp = LP_INTERP_FACING;
+ break;
+  case TGSI_SEMANTIC_POSITION:
+ /* Position was already emitted above
+  */
+ inputs[i].interp = LP_INTERP_POSITION;
+ inputs[i].src_index = 0;
+ continue;
+  case TGSI_SEMANTIC_COLOR:
+ /* Colors are linearly inputs[i].interpolated in the fragment shader
+  * even when flatshading is active.  This just tells the
+  * setup module to use coefficients with ddx==0 and
+  * ddy==0.
   */
- switch (lpfs->info.input_semantic_name[i]) {
- case TGSI_SEMANTIC_FACE:
-inputs[i].interp = LP_INTERP_FACING;
+ if (llvmpipe->rasterizer->flatshade)
+inputs[i].interp = LP_INTERP_CONSTANT;
+ else
+inputs[i].interp = LP_INTERP_LINEAR;
+ break;
+
+  default:
+ switch (lpfs->info.input_interpolate[i]) {
+ case TGSI_INTERPOLATE_CONSTANT:
+inputs[i].interp = LP_INTERP_CONSTANT;
 break;
- case TGSI_SEMANTIC_POSITION:
-inputs[i].interp = LP_INTERP_POSITION;
+ case TGSI_INTERPOLATE_LINEAR:
+inputs[i].interp = LP_INTERP_LINEAR;
 break;
- case TGSI_SEMANTIC_COLOR:
-/* Colors are linearly interpolated in the fragment shader
- * even when flatshading is active.  This just tells the
- * setup module to use coefficients with ddx==0 and
- * ddy==0.
- */
-if (llvmpipe->rasterizer->flatshade)
-   inputs[i].interp = LP_INTERP_CONSTANT;
-else
-   inputs[i].interp = LP_INTERP_LINEAR;
+ case TGSI_INTERPOLATE_PERSPECTIVE:
+inputs[i].interp = LP_INTERP_PERSPECTIVE;
 break;
-
  default:
-switch (lpfs->info.input_interpolate[i]) {
-case TGSI_INTERPOLATE_CONSTANT:
-   inputs[i].interp = LP_INTERP_CO

Mesa (gallium-index-bias): gallium: Add index bias parameter to draw_elements and friends.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: c184da9505e04fdbdda1bb1ff6990d5defaa25d4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c184da9505e04fdbdda1bb1ff6990d5defaa25d4

Author: José Fonseca 
Date:   Mon Apr 19 08:56:46 2010 +0200

gallium: Add index bias parameter to draw_elements and friends.

indexBias corresponds to:
- BaseVertexIndex parameter of D3D9's
  IDirect3DDevice9::DrawIndexedPrimitive method
- BaseVertexLocation parameter of ID3D10Device::DrawIndexed

Although a positive indexBias can be easily be implemented in Gallium by
adding indexBias*stride to each vertex buffer base offset, a negative
indexBias cannot, as the final vertex buffer offset could be negative.

I'm not aware of this functionality being exposed to GL drivers, so for
now all hardware drivers will just assert(indexBias == 0).

See also:
- http://msdn.microsoft.com/en-us/library/bb174369.aspx (D3D9)
- http://msdn.microsoft.com/en-us/library/ff556126.aspx (D3D10 DDI)

---

 src/gallium/include/pipe/p_context.h |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/gallium/include/pipe/p_context.h 
b/src/gallium/include/pipe/p_context.h
index 1aa0cbe..6f47845 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -67,6 +67,7 @@ struct pipe_context {
void (*draw_elements)( struct pipe_context *pipe,
   struct pipe_resource *indexBuffer,
   unsigned indexSize,
+  int indexBias,
   unsigned mode, unsigned start, unsigned count);
 
void (*draw_arrays_instanced)(struct pipe_context *pipe,
@@ -79,6 +80,7 @@ struct pipe_context {
void (*draw_elements_instanced)(struct pipe_context *pipe,
struct pipe_resource *indexBuffer,
unsigned indexSize,
+   int indexBias,
unsigned mode,
unsigned start,
unsigned count,
@@ -93,6 +95,7 @@ struct pipe_context {
void (*draw_range_elements)( struct pipe_context *pipe,
 struct pipe_resource *indexBuffer,
 unsigned indexSize,
+int indexBias,
 unsigned minIndex,
 unsigned maxIndex,
 unsigned mode, 

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


Mesa (gallium-index-bias): docs: Document indexBias.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 857c7c7ca266df4be8d4c725e056f69d4ee96624
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=857c7c7ca266df4be8d4c725e056f69d4ee96624

Author: José Fonseca 
Date:   Mon Apr 19 15:08:14 2010 +0200

docs: Document indexBias.

---

 src/gallium/docs/source/context.rst |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/gallium/docs/source/context.rst 
b/src/gallium/docs/source/context.rst
index 7439d10..69e0fcc 100644
--- a/src/gallium/docs/source/context.rst
+++ b/src/gallium/docs/source/context.rst
@@ -153,6 +153,9 @@ vertex attributes.
 If ``indexBuffer`` is NULL, the sequential numbers are used directly
 as indices to fetch vertex attributes.
 
+``indexBias`` is a value which is added to every index read from the index 
+buffer before fetching vertex attributes.
+
 If a given vertex element has ``instance_divisor`` set to 0, it is said
 it contains per-vertex data and effective vertex attribute address needs
 to be recalculated for every index.

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


Mesa (gallium-index-bias): cell: Implement index bias.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 150d12679d4d2550e0e54d76a43d153c4254ddfe
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=150d12679d4d2550e0e54d76a43d153c4254ddfe

Author: José Fonseca 
Date:   Mon Apr 19 18:14:23 2010 +0200

cell: Implement index bias.

---

 src/gallium/drivers/cell/ppu/cell_draw_arrays.c |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c 
b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
index 80e94a7..b50a30b 100644
--- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
+++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
@@ -59,6 +59,7 @@ static void
 cell_draw_range_elements(struct pipe_context *pipe,
  struct pipe_resource *indexBuffer,
  unsigned indexSize,
+ int indexBias,
  unsigned min_index,
  unsigned max_index,
  unsigned mode, unsigned start, unsigned count)
@@ -84,11 +85,11 @@ cell_draw_range_elements(struct pipe_context *pipe,
/* Map index buffer, if present */
if (indexBuffer) {
   void *mapped_indexes = cell_resource(indexBuffer)->data;
-  draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
+  draw_set_mapped_element_buffer(draw, indexSize, indexBias, 
mapped_indexes);
}
else {
   /* no index/element buffer */
-  draw_set_mapped_element_buffer(draw, 0, NULL);
+  draw_set_mapped_element_buffer(draw, 0, 0, NULL);
}
 
 
@@ -117,11 +118,11 @@ cell_draw_range_elements(struct pipe_context *pipe,
 static void
 cell_draw_elements(struct pipe_context *pipe,
struct pipe_resource *indexBuffer,
-   unsigned indexSize,
+   unsigned indexSize, int indexBias,
unsigned mode, unsigned start, unsigned count)
 {
cell_draw_range_elements( pipe, indexBuffer,
- indexSize,
+ indexSize, indeBias,
  0, 0x,
  mode, start, count );
 }
@@ -131,7 +132,7 @@ static void
 cell_draw_arrays(struct pipe_context *pipe, unsigned mode,
  unsigned start, unsigned count)
 {
-   cell_draw_elements(pipe, NULL, 0, mode, start, count);
+   cell_draw_elements(pipe, NULL, 0, 0, mode, start, count);
 }
 
 

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


Mesa (gallium-index-bias): draw: Implement index bias.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 2197fac47cb1f87387820678357cc67c9a2536b9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2197fac47cb1f87387820678357cc67c9a2536b9

Author: José Fonseca 
Date:   Mon Apr 19 18:14:04 2010 +0200

draw: Implement index bias.

---

 src/gallium/auxiliary/draw/draw_context.c  |4 +
 src/gallium/auxiliary/draw/draw_context.h  |2 +
 src/gallium/auxiliary/draw/draw_private.h  |1 +
 src/gallium/auxiliary/draw/draw_pt.c   |6 ++-
 src/gallium/auxiliary/draw/draw_pt.h   |1 +
 .../auxiliary/draw/draw_pt_varray_tmp_linear.h |3 +
 src/gallium/auxiliary/draw/draw_pt_vcache.c|   17 +++--
 src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h|   77 ++--
 8 files changed, 65 insertions(+), 46 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_context.c 
b/src/gallium/auxiliary/draw/draw_context.c
index 99f4e6d..b6c558b 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -427,12 +427,14 @@ void draw_set_render( struct draw_context *draw,
 void
 draw_set_mapped_element_buffer_range( struct draw_context *draw,
   unsigned eltSize,
+  int eltBias,
   unsigned min_index,
   unsigned max_index,
   const void *elements )
 {
draw->pt.user.elts = elements;
draw->pt.user.eltSize = eltSize;
+   draw->pt.user.eltBias = eltBias;
draw->pt.user.min_index = min_index;
draw->pt.user.max_index = max_index;
 }
@@ -441,10 +443,12 @@ draw_set_mapped_element_buffer_range( struct draw_context 
*draw,
 void
 draw_set_mapped_element_buffer( struct draw_context *draw,
 unsigned eltSize,
+int eltBias,
 const void *elements )
 {
draw->pt.user.elts = elements;
draw->pt.user.eltSize = eltSize;
+   draw->pt.user.eltBias = eltBias;
draw->pt.user.min_index = 0;
draw->pt.user.max_index = 0x;
 }
diff --git a/src/gallium/auxiliary/draw/draw_context.h 
b/src/gallium/auxiliary/draw/draw_context.h
index 1af4961..cfa0ad8 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -139,12 +139,14 @@ void draw_set_vertex_elements(struct draw_context *draw,
 void
 draw_set_mapped_element_buffer_range( struct draw_context *draw,
   unsigned eltSize,
+  int eltBias,
   unsigned min_index,
   unsigned max_index,
   const void *elements );
 
 void draw_set_mapped_element_buffer( struct draw_context *draw,
  unsigned eltSize, 
+ int eltBias,
  const void *elements );
 
 void draw_set_mapped_vertex_buffer(struct draw_context *draw,
diff --git a/src/gallium/auxiliary/draw/draw_private.h 
b/src/gallium/auxiliary/draw/draw_private.h
index da64102..33b0c19 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -148,6 +148,7 @@ struct draw_context
  const void *elts;
  /** bytes per index (0, 1, 2 or 4) */
  unsigned eltSize;
+ int eltBias;
  unsigned min_index;
  unsigned max_index;
  
diff --git a/src/gallium/auxiliary/draw/draw_pt.c 
b/src/gallium/auxiliary/draw/draw_pt.c
index 43f6c56..aa1f706 100644
--- a/src/gallium/auxiliary/draw/draw_pt.c
+++ b/src/gallium/auxiliary/draw/draw_pt.c
@@ -111,6 +111,7 @@ draw_pt_arrays(struct draw_context *draw,
frontend->run(frontend, 
  draw_pt_elt_func(draw),
  draw_pt_elt_ptr(draw, start),
+ draw->pt.user.eltBias,
  count);
 
frontend->finish( frontend );
@@ -222,8 +223,11 @@ draw_print_arrays(struct draw_context *draw, uint prim, 
int start, uint count)
 break;
  default:
 assert(0);
+return;
  }
- debug_printf("Element[%u + %u] -> Vertex %u:\n", start, i, ii);
+ ii += draw->pt.user.eltBias;
+ debug_printf("Element[%u + %u] + %i -> Vertex %u:\n", start, i,
+  draw->pt.user.eltBias, ii);
   }
   else {
  /* non-indexed arrays */
diff --git a/src/gallium/auxiliary/draw/draw_pt.h 
b/src/gallium/auxiliary/draw/draw_pt.h
index c2797a7..3e3ea32 100644
--- a/src/gallium/auxiliary/draw/draw_pt.h
+++ b/src/gallium/auxiliary/draw/draw_pt.h
@@ -67,6 +67,7 @@ struct draw_pt_front_end {
void (*run)( struct draw_pt_front_end *,
 pt_elt_func elt_func,
 const void *elt_ptr,
+  

Mesa (gallium-index-bias): failover: Implement index bias.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: f8d4638a092d44c0746ff124d3414c20c735e9f6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8d4638a092d44c0746ff124d3414c20c735e9f6

Author: José Fonseca 
Date:   Mon Apr 19 18:14:35 2010 +0200

failover: Implement index bias.

---

 src/gallium/drivers/failover/fo_context.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/failover/fo_context.c 
b/src/gallium/drivers/failover/fo_context.c
index 325a100..236c50f 100644
--- a/src/gallium/drivers/failover/fo_context.c
+++ b/src/gallium/drivers/failover/fo_context.c
@@ -53,6 +53,7 @@ void failover_fail_over( struct failover_context *failover )
 static void failover_draw_elements( struct pipe_context *pipe,
 struct pipe_resource *indexResource,
 unsigned indexSize,
+int indexBias,
 unsigned prim, 
 unsigned start, 
 unsigned count)
@@ -72,6 +73,7 @@ static void failover_draw_elements( struct pipe_context *pipe,
   failover->hw->draw_elements( failover->hw, 
indexResource, 
indexSize, 
+   indexBias,
prim, 
start, 
count );
@@ -89,6 +91,7 @@ static void failover_draw_elements( struct pipe_context *pipe,
   failover->sw->draw_elements( failover->sw, 
   indexResource, 
   indexSize, 
+  indexBias,
   prim, 
   start, 
   count );
@@ -105,7 +108,7 @@ static void failover_draw_elements( struct pipe_context 
*pipe,
 static void failover_draw_arrays( struct pipe_context *pipe,
 unsigned prim, unsigned start, unsigned 
count)
 {
-   failover_draw_elements(pipe, NULL, 0, prim, start, count);
+   failover_draw_elements(pipe, NULL, 0, 0, prim, start, count);
 }
 
 static unsigned int

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


Mesa (gallium-index-bias): i915: Implement index bias.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 1e7facdd8fbbccbf6f384a4c9bbb394c176f2c4b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1e7facdd8fbbccbf6f384a4c9bbb394c176f2c4b

Author: José Fonseca 
Date:   Mon Apr 19 18:14:48 2010 +0200

i915: Implement index bias.

---

 src/gallium/drivers/i915/i915_context.c |   13 +++--
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.c 
b/src/gallium/drivers/i915/i915_context.c
index 4ae5291..beddc13 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -48,6 +48,7 @@ static void
 i915_draw_range_elements(struct pipe_context *pipe,
  struct pipe_resource *indexBuffer,
  unsigned indexSize,
+ int indexBias,
  unsigned min_index,
  unsigned max_index,
  unsigned prim, unsigned start, unsigned count)
@@ -72,12 +73,12 @@ i915_draw_range_elements(struct pipe_context *pipe,
 */
if (indexBuffer) {
   void *mapped_indexes = i915_buffer(indexBuffer)->data;
-  draw_set_mapped_element_buffer_range(draw, indexSize,
+  draw_set_mapped_element_buffer_range(draw, indexSize, indexBias,
min_index,
max_index,
mapped_indexes);
} else {
-  draw_set_mapped_element_buffer(draw, 0, NULL);
+  draw_set_mapped_element_buffer(draw, 0, 0, NULL);
}
 
 
@@ -99,18 +100,18 @@ i915_draw_range_elements(struct pipe_context *pipe,
}
 
if (indexBuffer) {
-  draw_set_mapped_element_buffer(draw, 0, NULL);
+  draw_set_mapped_element_buffer(draw, 0, 0, NULL);
}
 }
 
 static void
 i915_draw_elements(struct pipe_context *pipe,
struct pipe_resource *indexBuffer,
-   unsigned indexSize,
+   unsigned indexSize, int indexBias,
unsigned prim, unsigned start, unsigned count)
 {
i915_draw_range_elements(pipe, indexBuffer,
-indexSize,
+indexSize, indexBias,
 0, 0x,
 prim, start, count);
 }
@@ -119,7 +120,7 @@ static void
 i915_draw_arrays(struct pipe_context *pipe,
  unsigned prim, unsigned start, unsigned count)
 {
-   i915_draw_elements(pipe, NULL, 0, prim, start, count);
+   i915_draw_elements(pipe, NULL, 0, 0, prim, start, count);
 }
 
 

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


Mesa (gallium-index-bias): i965g: Implement index bias.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 9ca0f45d8af5aa3152350594093797210d052b6e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9ca0f45d8af5aa3152350594093797210d052b6e

Author: José Fonseca 
Date:   Mon Apr 19 18:14:58 2010 +0200

i965g: Implement index bias.

---

 src/gallium/drivers/i965/brw_draw.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/i965/brw_draw.c 
b/src/gallium/drivers/i965/brw_draw.c
index eb73ec2..4625c20 100644
--- a/src/gallium/drivers/i965/brw_draw.c
+++ b/src/gallium/drivers/i965/brw_draw.c
@@ -179,7 +179,7 @@ try_draw_range_elements(struct brw_context *brw,
 static void
 brw_draw_range_elements(struct pipe_context *pipe,
struct pipe_resource *index_buffer,
-   unsigned index_size,
+   unsigned index_size, int index_bias,
unsigned min_index,
unsigned max_index,
unsigned mode, unsigned start, unsigned count)
@@ -194,6 +194,8 @@ brw_draw_range_elements(struct pipe_context *pipe,
   debug_printf("PRIM: %s start %d count %d index_buffer %p\n",
u_prim_name(mode), start, count, (void *)index_buffer);
 
+   assert(index_bias == 0);
+
/* Potentially trigger upload of new index buffer.
 *
 * XXX: do we need to go through state validation to achieve this?
@@ -233,12 +235,12 @@ brw_draw_range_elements(struct pipe_context *pipe,
 static void
 brw_draw_elements(struct pipe_context *pipe,
  struct pipe_resource *index_buffer,
- unsigned index_size,
+ unsigned index_size, int index_bias,
  unsigned mode, 
  unsigned start, unsigned count)
 {
brw_draw_range_elements( pipe, index_buffer,
-index_size,
+index_size, index_bias,
 0, 0x,
 mode, 
 start, count );
@@ -248,7 +250,7 @@ static void
 brw_draw_arrays(struct pipe_context *pipe, unsigned mode,
  unsigned start, unsigned count)
 {
-   brw_draw_elements(pipe, NULL, 0, mode, start, count);
+   brw_draw_elements(pipe, NULL, 0, 0, mode, start, count);
 }
 
 

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


Mesa (gallium-index-bias): identity: Implement index bias.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 382e9cc07b9193924b0eaf840a4d34cade2c7d92
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=382e9cc07b9193924b0eaf840a4d34cade2c7d92

Author: José Fonseca 
Date:   Mon Apr 19 18:15:05 2010 +0200

identity: Implement index bias.

---

 src/gallium/drivers/identity/id_context.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/identity/id_context.c 
b/src/gallium/drivers/identity/id_context.c
index 3b7eaec..630cdb5 100644
--- a/src/gallium/drivers/identity/id_context.c
+++ b/src/gallium/drivers/identity/id_context.c
@@ -64,6 +64,7 @@ static void
 identity_draw_elements(struct pipe_context *_pipe,
struct pipe_resource *_indexResource,
unsigned indexSize,
+   int indexBias,
unsigned prim,
unsigned start,
unsigned count)
@@ -76,6 +77,7 @@ identity_draw_elements(struct pipe_context *_pipe,
pipe->draw_elements(pipe,
indexResource,
indexSize,
+   indexBias,
prim,
start,
count);
@@ -85,6 +87,7 @@ static void
 identity_draw_range_elements(struct pipe_context *_pipe,
  struct pipe_resource *_indexResource,
  unsigned indexSize,
+ int indexBias,
  unsigned minIndex,
  unsigned maxIndex,
  unsigned mode,
@@ -99,6 +102,7 @@ identity_draw_range_elements(struct pipe_context *_pipe,
pipe->draw_range_elements(pipe,
  indexResource,
  indexSize,
+ indexBias,
  minIndex,
  maxIndex,
  mode,

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


Mesa (gallium-index-bias): llvmpipe: Implement index bias.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: d27a53d46931d2286c90b21ff7f06f44a7a726bc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d27a53d46931d2286c90b21ff7f06f44a7a726bc

Author: José Fonseca 
Date:   Mon Apr 19 18:15:11 2010 +0200

llvmpipe: Implement index bias.

---

 src/gallium/drivers/llvmpipe/lp_draw_arrays.c |   12 +++-
 src/gallium/drivers/llvmpipe/lp_state.h   |4 ++--
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c 
b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
index 86525ee..0b63e1c 100644
--- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
+++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
@@ -46,7 +46,7 @@ void
 llvmpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
  unsigned start, unsigned count)
 {
-   llvmpipe_draw_elements(pipe, NULL, 0, mode, start, count);
+   llvmpipe_draw_elements(pipe, NULL, 0, 0, mode, start, count);
 }
 
 
@@ -59,6 +59,7 @@ void
 llvmpipe_draw_range_elements(struct pipe_context *pipe,
  struct pipe_resource *indexBuffer,
  unsigned indexSize,
+ int indexBias,
  unsigned min_index,
  unsigned max_index,
  unsigned mode, unsigned start, unsigned count)
@@ -81,14 +82,14 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe,
/* Map index buffer, if present */
if (indexBuffer) {
   void *mapped_indexes = llvmpipe_resource_data(indexBuffer);
-  draw_set_mapped_element_buffer_range(draw, indexSize,
+  draw_set_mapped_element_buffer_range(draw, indexSize, indexBias,
min_index,
max_index,
mapped_indexes);
}
else {
   /* no index/element buffer */
-  draw_set_mapped_element_buffer_range(draw, 0, start,
+  draw_set_mapped_element_buffer_range(draw, 0, 0, start,
start + count - 1, NULL);
}
 
@@ -102,7 +103,7 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe,
   draw_set_mapped_vertex_buffer(draw, i, NULL);
}
if (indexBuffer) {
-  draw_set_mapped_element_buffer(draw, 0, NULL);
+  draw_set_mapped_element_buffer(draw, 0, 0, NULL);
}
 
/*
@@ -118,10 +119,11 @@ void
 llvmpipe_draw_elements(struct pipe_context *pipe,
struct pipe_resource *indexBuffer,
unsigned indexSize,
+   int indexBias,
unsigned mode, unsigned start, unsigned count)
 {
llvmpipe_draw_range_elements( pipe, indexBuffer,
- indexSize,
+ indexSize, indexBias,
  0, 0x,
  mode, start, count );
 }
diff --git a/src/gallium/drivers/llvmpipe/lp_state.h 
b/src/gallium/drivers/llvmpipe/lp_state.h
index d89c28a..dcbff19 100644
--- a/src/gallium/drivers/llvmpipe/lp_state.h
+++ b/src/gallium/drivers/llvmpipe/lp_state.h
@@ -228,12 +228,12 @@ void llvmpipe_draw_arrays(struct pipe_context *pipe, 
unsigned mode,
 
 void llvmpipe_draw_elements(struct pipe_context *pipe,
   struct pipe_resource *indexBuffer,
-  unsigned indexSize,
+  unsigned indexSize, int indexBias,
   unsigned mode, unsigned start, unsigned count);
 void
 llvmpipe_draw_range_elements(struct pipe_context *pipe,
  struct pipe_resource *indexBuffer,
- unsigned indexSize,
+ unsigned indexSize, int indexBias,
  unsigned min_index,
  unsigned max_index,
  unsigned mode, unsigned start, unsigned count);

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


Mesa (gallium-index-bias): softpipe: Implement index bias.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 989861fc5ea1792e7ea1be07389db7c3e3b8e383
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=989861fc5ea1792e7ea1be07389db7c3e3b8e383

Author: José Fonseca 
Date:   Mon Apr 19 18:15:39 2010 +0200

softpipe: Implement index bias.

---

 src/gallium/drivers/softpipe/sp_draw_arrays.c |   16 +---
 src/gallium/drivers/softpipe/sp_state.h   |4 +++-
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c 
b/src/gallium/drivers/softpipe/sp_draw_arrays.c
index 461c9a6..b30036e 100644
--- a/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -57,6 +57,7 @@ static void
 softpipe_draw_range_elements_instanced(struct pipe_context *pipe,
struct pipe_resource *indexBuffer,
unsigned indexSize,
+   int indexBias,
unsigned minIndex,
unsigned maxIndex,
unsigned mode,
@@ -74,6 +75,7 @@ softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
   NULL,
   0,
   0,
+  0,
   0x,
   mode,
   start,
@@ -87,6 +89,7 @@ void
 softpipe_draw_range_elements(struct pipe_context *pipe,
  struct pipe_resource *indexBuffer,
  unsigned indexSize,
+ int indexBias,
  unsigned min_index,
  unsigned max_index,
  unsigned mode, unsigned start, unsigned count)
@@ -94,6 +97,7 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
softpipe_draw_range_elements_instanced(pipe,
   indexBuffer,
   indexSize,
+  indexBias,
   min_index,
   max_index,
   mode,
@@ -107,12 +111,13 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
 void
 softpipe_draw_elements(struct pipe_context *pipe,
struct pipe_resource *indexBuffer,
-   unsigned indexSize,
+   unsigned indexSize, int indexBias,
unsigned mode, unsigned start, unsigned count)
 {
softpipe_draw_range_elements_instanced(pipe,
   indexBuffer,
   indexSize,
+  indexBias,
   0,
   0x,
   mode,
@@ -134,6 +139,7 @@ softpipe_draw_arrays_instanced(struct pipe_context *pipe,
   NULL,
   0,
   0,
+  0,
   0x,
   mode,
   start,
@@ -146,6 +152,7 @@ void
 softpipe_draw_elements_instanced(struct pipe_context *pipe,
  struct pipe_resource *indexBuffer,
  unsigned indexSize,
+ int indexBias,
  unsigned mode,
  unsigned start,
  unsigned count,
@@ -155,6 +162,7 @@ softpipe_draw_elements_instanced(struct pipe_context *pipe,
softpipe_draw_range_elements_instanced(pipe,
   indexBuffer,
   indexSize,
+  indexBias,
   0,
   0x,
   mode,
@@ -168,6 +176,7 @@ static void
 softpipe_draw_range_elements_instanced(struct pipe_context *pipe,
struct pipe_resource *indexBuffer,
unsigned indexSize,
+   int indexBias,
unsigned minIndex,
unsigned maxIndex,
unsigned mode,
@@ -202,13 +211,14 @@ softpipe_draw_range_elements_instanced(struct 
pipe_cont

Mesa (gallium-index-bias): svga: Implement index bias.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 9515b78859b52b4532cc9e06366428f2c49c7869
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9515b78859b52b4532cc9e06366428f2c49c7869

Author: José Fonseca 
Date:   Mon Apr 19 18:16:08 2010 +0200

svga: Implement index bias.

Untested.

---

 src/gallium/drivers/svga/svga_draw.h  |4 ++--
 src/gallium/drivers/svga/svga_draw_elements.c |   17 +
 src/gallium/drivers/svga/svga_draw_private.h  |4 ++--
 src/gallium/drivers/svga/svga_pipe_draw.c |   16 ++--
 src/gallium/drivers/svga/svga_swtnl.h |1 +
 src/gallium/drivers/svga/svga_swtnl_backend.c |8 +---
 src/gallium/drivers/svga/svga_swtnl_draw.c|5 +++--
 7 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_draw.h 
b/src/gallium/drivers/svga/svga_draw.h
index 81c7f83..a2403d8 100644
--- a/src/gallium/drivers/svga/svga_draw.h
+++ b/src/gallium/drivers/svga/svga_draw.h
@@ -69,12 +69,12 @@ enum pipe_error
 svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
 struct pipe_resource *indexBuffer,
 unsigned index_size,
+int index_bias,
 unsigned min_index,
 unsigned max_index,
 unsigned prim, 
 unsigned start, 
-unsigned count,
-unsigned bias );
+unsigned count );
 
 enum pipe_error
 svga_hwtnl_flush( struct svga_hwtnl *hwtnl );
diff --git a/src/gallium/drivers/svga/svga_draw_elements.c 
b/src/gallium/drivers/svga/svga_draw_elements.c
index 7ec4a05..c457917 100644
--- a/src/gallium/drivers/svga/svga_draw_elements.c
+++ b/src/gallium/drivers/svga/svga_draw_elements.c
@@ -99,12 +99,12 @@ enum pipe_error
 svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl,
struct pipe_resource *index_buffer,
unsigned index_size,
+   int index_bias,
unsigned min_index,
unsigned max_index,
unsigned prim, 
unsigned start,
-   unsigned count,
-   unsigned bias )
+   unsigned count )
 {
struct pipe_resource *upload_buffer = NULL;
SVGA3dPrimitiveRange range;
@@ -143,7 +143,7 @@ svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl 
*hwtnl,
range.indexArray.offset = index_offset;
range.indexArray.stride = index_size;
range.indexWidth = index_size;
-   range.indexBias = bias;
+   range.indexBias = index_bias;
   
ret = svga_hwtnl_prim( hwtnl, &range, min_index, max_index, index_buffer );
if (ret)
@@ -163,10 +163,10 @@ enum pipe_error
 svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
 struct pipe_resource *index_buffer,
 unsigned index_size,
+int index_bias,
 unsigned min_index,
 unsigned max_index,
-unsigned prim, unsigned start, unsigned count,
-unsigned bias)
+unsigned prim, unsigned start, unsigned count)
 {
unsigned gen_prim, gen_size, gen_nr, gen_type;
u_translate_func gen_func;
@@ -204,9 +204,10 @@ svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
*/
   return svga_hwtnl_simple_draw_range_elements( hwtnl, index_buffer,
 index_size,
+index_bias,
 min_index,
 max_index,
-gen_prim, start, count, 
bias );
+gen_prim, start, count );
}
else {
   struct pipe_resource *gen_buf = NULL;
@@ -231,12 +232,12 @@ svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
   ret = svga_hwtnl_simple_draw_range_elements( hwtnl,
gen_buf,
gen_size,
+   index_bias,
min_index,
max_index,
gen_prim,
0,
-   

Mesa (gallium-index-bias): st/python: Use index bias.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 5620216c984cdbc8983bc1861ebb09380f3467e4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5620216c984cdbc8983bc1861ebb09380f3467e4

Author: José Fonseca 
Date:   Mon Apr 19 18:16:34 2010 +0200

st/python: Use index bias.

---

 src/gallium/state_trackers/python/p_context.i |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/gallium/state_trackers/python/p_context.i 
b/src/gallium/state_trackers/python/p_context.i
index 13c8d1a..3c5509c 100644
--- a/src/gallium/state_trackers/python/p_context.i
+++ b/src/gallium/state_trackers/python/p_context.i
@@ -312,22 +312,24 @@ struct st_context {
}
 
void draw_elements( struct pipe_resource *indexBuffer,
-   unsigned indexSize,
+   unsigned indexSize, int indexBias,
unsigned mode, unsigned start, unsigned count) 
{
   $self->pipe->draw_elements($self->pipe, 
  indexBuffer, 
  indexSize, 
+ indexBias,
  mode, start, count);
}
 
void draw_range_elements( struct pipe_resource *indexBuffer,
- unsigned indexSize, unsigned minIndex, unsigned 
maxIndex,
+ unsigned indexSize, int indexBias,
+ unsigned minIndex, unsigned maxIndex,
  unsigned mode, unsigned start, unsigned count)
{
   $self->pipe->draw_range_elements($self->pipe, 
-   indexBuffer, 
-   indexSize, minIndex, maxIndex,
+   indexBuffer, indexSize, indexBias,
+   minIndex, maxIndex,
mode, start, count);
}
 

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


Mesa (gallium-index-bias): trace: Implement index bias.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 8b658580ee2ad33aa9c7438b1efc6c35d6bfab00
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b658580ee2ad33aa9c7438b1efc6c35d6bfab00

Author: José Fonseca 
Date:   Mon Apr 19 18:16:20 2010 +0200

trace: Implement index bias.

---

 src/gallium/drivers/trace/tr_context.c |   16 ++--
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/trace/tr_context.c 
b/src/gallium/drivers/trace/tr_context.c
index 512acb7..8216c06 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -176,9 +176,9 @@ trace_context_draw_arrays(struct pipe_context *_pipe,
 
 static INLINE void
 trace_context_draw_elements(struct pipe_context *_pipe,
-  struct pipe_resource *_indexBuffer,
-  unsigned indexSize,
-  unsigned mode, unsigned start, unsigned count)
+struct pipe_resource *_indexBuffer,
+unsigned indexSize, int indexBias,
+unsigned mode, unsigned start, unsigned count)
 {
struct trace_context *tr_ctx = trace_context(_pipe);
struct trace_resource *tr_buf = trace_resource(_indexBuffer);
@@ -195,11 +195,13 @@ trace_context_draw_elements(struct pipe_context *_pipe,
trace_dump_arg(ptr, pipe);
trace_dump_arg(ptr, indexBuffer);
trace_dump_arg(uint, indexSize);
+   trace_dump_arg(int, indexBias);
trace_dump_arg(uint, mode);
trace_dump_arg(uint, start);
trace_dump_arg(uint, count);
 
-   pipe->draw_elements(pipe, indexBuffer, indexSize, mode, start, count);
+   pipe->draw_elements(pipe, indexBuffer, indexSize, indexBias,
+   mode, start, count);
 
trace_dump_call_end();
 
@@ -211,6 +213,7 @@ static INLINE void
 trace_context_draw_range_elements(struct pipe_context *_pipe,
   struct pipe_resource *_indexBuffer,
   unsigned indexSize,
+  int indexBias,
   unsigned minIndex,
   unsigned maxIndex,
   unsigned mode,
@@ -232,6 +235,7 @@ trace_context_draw_range_elements(struct pipe_context 
*_pipe,
trace_dump_arg(ptr, pipe);
trace_dump_arg(ptr, indexBuffer);
trace_dump_arg(uint, indexSize);
+   trace_dump_arg(int, indexBias);
trace_dump_arg(uint, minIndex);
trace_dump_arg(uint, maxIndex);
trace_dump_arg(uint, mode);
@@ -239,8 +243,8 @@ trace_context_draw_range_elements(struct pipe_context 
*_pipe,
trace_dump_arg(uint, count);
 
pipe->draw_range_elements(pipe,
- indexBuffer,
- indexSize, minIndex, maxIndex,
+ indexBuffer, indexSize, indexBias,
+ minIndex, maxIndex,
  mode, start, count);
 
trace_dump_call_end();

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


Mesa (gallium-index-bias): mesa/st: Update for index bias interface change.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 17a43c1718605e4c95bcd7f554b0a5b8293d2578
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=17a43c1718605e4c95bcd7f554b0a5b8293d2578

Author: José Fonseca 
Date:   Mon Apr 19 18:16:57 2010 +0200

mesa/st: Update for index bias interface change.

---

 src/mesa/state_tracker/st_draw.c  |6 +++---
 src/mesa/state_tracker/st_draw_feedback.c |8 
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 4f4368a..a362035 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -676,7 +676,7 @@ st_draw_vbo(GLcontext *ctx,
  for (i = 0; i < nr_prims; i++) {
 prim = translate_prim( ctx, prims[i].mode );
 
-pipe->draw_range_elements(pipe, indexBuf, indexSize,
+pipe->draw_range_elements(pipe, indexBuf, indexSize, 0,
   min_index, max_index, prim,
   prims[i].start + indexOffset, 
prims[i].count);
  }
@@ -686,12 +686,12 @@ st_draw_vbo(GLcontext *ctx,
 prim = translate_prim( ctx, prims[i].mode );
 
 if (prims[i].num_instances == 1) {
-   pipe->draw_elements(pipe, indexBuf, indexSize, prim,
+   pipe->draw_elements(pipe, indexBuf, indexSize, 0, prim,
prims[i].start + indexOffset,
prims[i].count);
 }
 else {
-   pipe->draw_elements_instanced(pipe, indexBuf, indexSize, prim,
+   pipe->draw_elements_instanced(pipe, indexBuf, indexSize, 0, 
prim,
  prims[i].start + indexOffset,
  prims[i].count,
  0, prims[i].num_instances);
diff --git a/src/mesa/state_tracker/st_draw_feedback.c 
b/src/mesa/state_tracker/st_draw_feedback.c
index 0473046..a28ad8e 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -229,16 +229,16 @@ st_feedback_draw_vbo(GLcontext *ctx,
  map = pipe_buffer_map(pipe, index_buffer_handle,
PIPE_TRANSFER_READ, &ib_transfer);
 
- draw_set_mapped_element_buffer(draw, indexSize, map);
+ draw_set_mapped_element_buffer(draw, indexSize, 0, map);
   }
   else {
- draw_set_mapped_element_buffer(draw, indexSize, (void *) ib->ptr);
+ draw_set_mapped_element_buffer(draw, indexSize, 0, (void *) ib->ptr);
 ib_transfer = NULL;
   }
}
else {
   /* no index/element buffer */
-  draw_set_mapped_element_buffer(draw, 0, NULL);
+  draw_set_mapped_element_buffer(draw, 0, 0, NULL);
}
 
 
@@ -275,7 +275,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
}
if (index_buffer_handle) {
   pipe_buffer_unmap(pipe, index_buffer_handle, ib_transfer);
-  draw_set_mapped_element_buffer(draw, 0, NULL);
+  draw_set_mapped_element_buffer(draw, 0, 0, NULL);
}
 }
 

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


Mesa (gallium-index-bias): retrace: Support index bias.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 583f51ba4bb1029d9d4f338ca3c8f4702abc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=583f51ba4bb1029d9d4f338ca3c8f4702abc

Author: José Fonseca 
Date:   Mon Apr 19 18:17:11 2010 +0200

retrace: Support index bias.

---

 src/gallium/tests/python/retrace/interpreter.py |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/gallium/tests/python/retrace/interpreter.py 
b/src/gallium/tests/python/retrace/interpreter.py
index 88b3bbd..7118ff8 100755
--- a/src/gallium/tests/python/retrace/interpreter.py
+++ b/src/gallium/tests/python/retrace/interpreter.py
@@ -496,7 +496,7 @@ class Context(Object):
 sys.stdout.write('\t},\n')
 sys.stdout.flush()
 
-def dump_indices(self, ibuf, isize, start, count):
+def dump_indices(self, ibuf, isize, ibias, start, count):
 if not self.interpreter.verbosity(2):
 return
 
@@ -524,7 +524,7 @@ class Context(Object):
 sys.stdout.write('\t},\n')
 sys.stdout.flush()
 
-return minindex, maxindex
+return minindex + ibias, maxindex + ibias
 
 def draw_arrays(self, mode, start, count):
 self.dump_vertices(start, count)
@@ -532,22 +532,22 @@ class Context(Object):
 self.real.draw_arrays(mode, start, count)
 self._set_dirty()
 
-def draw_elements(self, indexBuffer, indexSize, mode, start, count):
+def draw_elements(self, indexBuffer, indexSize, indexBias, mode, start, 
count):
 if self.interpreter.verbosity(2):
-minindex, maxindex = self.dump_indices(indexBuffer, indexSize, 
start, count)
+minindex, maxindex = self.dump_indices(indexBuffer, indexSize, 
indexBias, start, count)
 self.dump_vertices(minindex, maxindex - minindex)
 
-self.real.draw_elements(indexBuffer, indexSize, mode, start, count)
+self.real.draw_elements(indexBuffer, indexSize, indexBias, mode, 
start, count)
 self._set_dirty()
 
-def draw_range_elements(self, indexBuffer, indexSize, minIndex, maxIndex, 
mode, start, count):
+def draw_range_elements(self, indexBuffer, indexSize, indexBias, minIndex, 
maxIndex, mode, start, count):
 if self.interpreter.verbosity(2):
-minindex, maxindex = self.dump_indices(indexBuffer, indexSize, 
start, count)
+minindex, maxindex = self.dump_indices(indexBuffer, indexSize, 
indexBias, start, count)
 minindex = min(minindex, minIndex)
 maxindex = min(maxindex, maxIndex)
 self.dump_vertices(minindex, maxindex - minindex)
 
-self.real.draw_range_elements(indexBuffer, indexSize, minIndex, 
maxIndex, mode, start, count)
+self.real.draw_range_elements(indexBuffer, indexSize, indexBias, 
minIndex, maxIndex, mode, start, count)
 self._set_dirty()
 
 def surface_copy(self, dest, destx, desty, src, srcx, srcy, width, height):

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


Mesa (gallium-index-bias): nvfx: Adapt for index bias interface change.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 7c785c0d2c2b5f3ead4b3cf31ad6af02bd90f3a5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7c785c0d2c2b5f3ead4b3cf31ad6af02bd90f3a5

Author: José Fonseca 
Date:   Mon Apr 19 18:18:28 2010 +0200

nvfx: Adapt for index bias interface change.

---

 src/gallium/drivers/nvfx/nvfx_context.h |   15 ---
 src/gallium/drivers/nvfx/nvfx_draw.c|7 ---
 src/gallium/drivers/nvfx/nvfx_vbo.c |   18 --
 3 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/nvfx/nvfx_context.h 
b/src/gallium/drivers/nvfx/nvfx_context.h
index e2c6d09..e48f9f3 100644
--- a/src/gallium/drivers/nvfx/nvfx_context.h
+++ b/src/gallium/drivers/nvfx/nvfx_context.h
@@ -175,9 +175,10 @@ extern void nvfx_clear(struct pipe_context *pipe, unsigned 
buffers,
 /* nvfx_draw.c */
 extern struct draw_stage *nvfx_draw_render_stage(struct nvfx_context *nvfx);
 extern void nvfx_draw_elements_swtnl(struct pipe_context *pipe,
-   struct pipe_resource *idxbuf,
-   unsigned ib_size, unsigned mode,
-   unsigned start, unsigned count);
+ struct pipe_resource *idxbuf,
+ unsigned ib_size, int ib_bias,
+ unsigned mode,
+ unsigned start, unsigned count);
 extern void nvfx_vtxfmt_validate(struct nvfx_context *nvfx);
 
 /* nvfx_fb.c */
@@ -237,10 +238,10 @@ extern void nvfx_vbo_relocate(struct nvfx_context *nvfx);
 extern void nvfx_draw_arrays(struct pipe_context *, unsigned mode,
unsigned start, unsigned count);
 extern void nvfx_draw_elements(struct pipe_context *pipe,
- struct pipe_resource *indexBuffer,
- unsigned indexSize,
- unsigned mode, unsigned start,
- unsigned count);
+   struct pipe_resource *indexBuffer,
+   unsigned indexSize, int indexBias,
+   unsigned mode, unsigned start,
+   unsigned count);
 
 /* nvfx_vertprog.c */
 extern boolean nvfx_vertprog_validate(struct nvfx_context *nvfx);
diff --git a/src/gallium/drivers/nvfx/nvfx_draw.c 
b/src/gallium/drivers/nvfx/nvfx_draw.c
index 5eadce1..55b72ac 100644
--- a/src/gallium/drivers/nvfx/nvfx_draw.c
+++ b/src/gallium/drivers/nvfx/nvfx_draw.c
@@ -232,7 +232,8 @@ nvfx_draw_render_stage(struct nvfx_context *nvfx)
 
 void
 nvfx_draw_elements_swtnl(struct pipe_context *pipe,
-struct pipe_resource *idxbuf, unsigned idxbuf_size,
+struct pipe_resource *idxbuf,
+unsigned idxbuf_size, int idxbuf_bias,
 unsigned mode, unsigned start, unsigned count)
 {
struct nvfx_context *nvfx = nvfx_context(pipe);
@@ -257,9 +258,9 @@ nvfx_draw_elements_swtnl(struct pipe_context *pipe,
map = pipe_buffer_map(pipe, idxbuf,
  PIPE_TRANSFER_READ,
  &ib_transfer);
-   draw_set_mapped_element_buffer(nvfx->draw, idxbuf_size, map);
+   draw_set_mapped_element_buffer(nvfx->draw, idxbuf_size, 
idx_bufbias, map);
} else {
-   draw_set_mapped_element_buffer(nvfx->draw, 0, NULL);
+   draw_set_mapped_element_buffer(nvfx->draw, 0, 0, NULL);
}
 
if (nvfx->constbuf[PIPE_SHADER_VERTEX]) {
diff --git a/src/gallium/drivers/nvfx/nvfx_vbo.c 
b/src/gallium/drivers/nvfx/nvfx_vbo.c
index 5ffbdfc..d441d03 100644
--- a/src/gallium/drivers/nvfx/nvfx_vbo.c
+++ b/src/gallium/drivers/nvfx/nvfx_vbo.c
@@ -167,7 +167,7 @@ nvfx_draw_arrays(struct pipe_context *pipe,
 
nvfx_vbo_set_idxbuf(nvfx, NULL, 0);
if (nvfx->screen->force_swtnl || !nvfx_state_validate(nvfx)) {
-   nvfx_draw_elements_swtnl(pipe, NULL, 0,
+   nvfx_draw_elements_swtnl(pipe, NULL, 0, 0,
mode, start, count);
 return;
}
@@ -372,7 +372,8 @@ nvfx_draw_elements_u32(struct nvfx_context *nvfx, void *ib,
 
 static void
 nvfx_draw_elements_inline(struct pipe_context *pipe,
- struct pipe_resource *ib, unsigned ib_size,
+ struct pipe_resource *ib,
+ unsigned ib_size, int ib_bias,
  unsigned mode, unsigned start, unsigned count)
 {
struct nvfx_context *nvfx = nvfx_context(pipe);
@@ -385,6 +386,8 @@ nvfx_draw_elements_inline(struct pipe_context *pipe,
return;
}
 
+   assert(ib_bias == 0);
+
switch (ib_size) {
case 1:
nvfx_draw_elements_u08(nvfx, map,

Mesa (gallium-index-bias): nv50: Adapt for index bias interface change.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: f6f7324bbf03494dc26e266d96919fec6a1f08ba
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f6f7324bbf03494dc26e266d96919fec6a1f08ba

Author: José Fonseca 
Date:   Mon Apr 19 18:17:45 2010 +0200

nv50: Adapt for index bias interface change.

---

 src/gallium/drivers/nv50/nv50_context.h |4 ++--
 src/gallium/drivers/nv50/nv50_push.c|4 +++-
 src/gallium/drivers/nv50/nv50_vbo.c |9 ++---
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_context.h 
b/src/gallium/drivers/nv50/nv50_context.h
index 8bf4653..4875f83 100644
--- a/src/gallium/drivers/nv50/nv50_context.h
+++ b/src/gallium/drivers/nv50/nv50_context.h
@@ -185,12 +185,12 @@ extern void nv50_draw_arrays_instanced(struct 
pipe_context *, unsigned mode,
unsigned instanceCount);
 extern void nv50_draw_elements(struct pipe_context *pipe,
  struct pipe_resource *indexBuffer,
- unsigned indexSize,
+ unsigned indexSize, int indexBias,
  unsigned mode, unsigned start,
  unsigned count);
 extern void nv50_draw_elements_instanced(struct pipe_context *pipe,
 struct pipe_resource *indexBuffer,
-unsigned indexSize,
+unsigned indexSize, int indexBias,
 unsigned mode, unsigned start,
 unsigned count,
 unsigned startInstance,
diff --git a/src/gallium/drivers/nv50/nv50_push.c 
b/src/gallium/drivers/nv50/nv50_push.c
index 6981e5b..c54fed5 100644
--- a/src/gallium/drivers/nv50/nv50_push.c
+++ b/src/gallium/drivers/nv50/nv50_push.c
@@ -172,7 +172,8 @@ emit_verts(void *priv, unsigned start, unsigned count)
 
 void
 nv50_push_elements_instanced(struct pipe_context *pipe,
- struct pipe_resource *idxbuf, unsigned idxsize,
+ struct pipe_resource *idxbuf,
+ unsigned idxsize, int idxbias,
  unsigned mode, unsigned start, unsigned count,
  unsigned i_start, unsigned i_count)
 {
@@ -269,6 +270,7 @@ nv50_push_elements_instanced(struct pipe_context *pipe,
   }
   ctx.idxbuf = bo->map;
   ctx.idxsize = idxsize;
+  assert(idxbias == 0);
   nouveau_bo_unmap(bo);
}
 
diff --git a/src/gallium/drivers/nv50/nv50_vbo.c 
b/src/gallium/drivers/nv50/nv50_vbo.c
index 609145d..932c1e8 100644
--- a/src/gallium/drivers/nv50/nv50_vbo.c
+++ b/src/gallium/drivers/nv50/nv50_vbo.c
@@ -387,7 +387,7 @@ nv50_draw_elements_inline(struct pipe_context *pipe,
 void
 nv50_draw_elements_instanced(struct pipe_context *pipe,
 struct pipe_resource *indexBuffer,
-unsigned indexSize,
+unsigned indexSize, int indexBias,
 unsigned mode, unsigned start, unsigned count,
 unsigned startInstance, unsigned instanceCount)
 {
@@ -401,6 +401,8 @@ nv50_draw_elements_instanced(struct pipe_context *pipe,
if (!nv50_state_validate(nv50, 13 + 16*3))
return;
 
+   assert(indexBias == 0);
+
if (nv50->vbo_fifo) {
nv50_push_elements_instanced(pipe, indexBuffer, indexSize,
 mode, start, count, startInstance,
@@ -460,10 +462,11 @@ nv50_draw_elements_instanced(struct pipe_context *pipe,
 
 void
 nv50_draw_elements(struct pipe_context *pipe,
-  struct pipe_resource *indexBuffer, unsigned indexSize,
+  struct pipe_resource *indexBuffer,
+  unsigned indexSize, int indexBias,
   unsigned mode, unsigned start, unsigned count)
 {
-   nv50_draw_elements_instanced(pipe, indexBuffer, indexSize,
+   nv50_draw_elements_instanced(pipe, indexBuffer, indexSize, indexBias,
 mode, start, count, 0, 1);
 }
 

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


Mesa (gallium-index-bias): r300g: Adapt for index bias interface change.

2010-04-19 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: dfadf5a579281c6dd4ecdd4ecd5568fbbb1de17e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dfadf5a579281c6dd4ecdd4ecd5568fbbb1de17e

Author: José Fonseca 
Date:   Mon Apr 19 18:18:45 2010 +0200

r300g: Adapt for index bias interface change.

---

 src/gallium/drivers/r300/r300_context.h |3 +-
 src/gallium/drivers/r300/r300_render.c  |   42 ++
 src/gallium/drivers/r300/r300_render.h  |6 +++-
 3 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_context.h 
b/src/gallium/drivers/r300/r300_context.h
index 2e8601b..1e4fd9e 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -327,7 +327,8 @@ struct r300_context {
 
 void (*emit_draw_elements)(
 struct r300_context *r300, struct pipe_resource* indexBuffer,
-unsigned indexSize, unsigned minIndex, unsigned maxIndex,
+unsigned indexSize, int indexBias,
+unsigned minIndex, unsigned maxIndex,
 unsigned mode, unsigned start, unsigned count);
 
 
diff --git a/src/gallium/drivers/r300/r300_render.c 
b/src/gallium/drivers/r300/r300_render.c
index f6bc68c..007f01a 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -298,6 +298,7 @@ void r500_emit_draw_arrays(struct r300_context *r300,
 void r500_emit_draw_elements(struct r300_context *r300,
  struct pipe_resource* indexBuffer,
  unsigned indexSize,
+ int indexBias,
  unsigned minIndex,
  unsigned maxIndex,
  unsigned mode,
@@ -319,6 +320,8 @@ void r500_emit_draw_elements(struct r300_context *r300,
 return;
 }
 
+assert(indexBias == 0);
+
 maxIndex = MIN2(maxIndex, r300->vertex_buffer_max_index);
 
 DBG(r300, DBG_DRAW, "r300: Indexbuf of %u indices, min %u max %u\n",
@@ -442,6 +445,7 @@ void r300_emit_draw_arrays(struct r300_context *r300,
 void r300_emit_draw_elements(struct r300_context *r300,
  struct pipe_resource* indexBuffer,
  unsigned indexSize,
+ int indexBias,
  unsigned minIndex,
  unsigned maxIndex,
  unsigned mode,
@@ -449,15 +453,15 @@ void r300_emit_draw_elements(struct r300_context *r300,
  unsigned count)
 {
 if (!r300->stencil_ref_bf_fallback) {
-r500_emit_draw_elements(r300, indexBuffer, indexSize, minIndex,
-maxIndex, mode, start, count);
+r500_emit_draw_elements(r300, indexBuffer, indexSize, indexBias,
+minIndex, maxIndex, mode, start, count);
 } else {
 r300_begin_stencil_ref_fallback(r300);
-r500_emit_draw_elements(r300, indexBuffer, indexSize, minIndex,
-maxIndex, mode, start, count);
+r500_emit_draw_elements(r300, indexBuffer, indexSize, indexBias,
+minIndex, maxIndex, mode, start, count);
 r300_switch_stencil_ref_side(r300);
-r500_emit_draw_elements(r300, indexBuffer, indexSize, minIndex,
-maxIndex, mode, start, count);
+r500_emit_draw_elements(r300, indexBuffer, indexSize, indexBias,
+minIndex, maxIndex, mode, start, count);
 r300_end_stencil_ref_fallback(r300);
 }
 }
@@ -528,6 +532,7 @@ static void r300_align_ushort_elts(struct r300_context 
*r300,
 void r300_draw_range_elements(struct pipe_context* pipe,
   struct pipe_resource* indexBuffer,
   unsigned indexSize,
+  int indexBias,
   unsigned minIndex,
   unsigned maxIndex,
   unsigned mode,
@@ -574,13 +579,14 @@ void r300_draw_range_elements(struct pipe_context* pipe,
 u_upload_flush(r300->upload_vb);
 u_upload_flush(r300->upload_ib);
 if (alt_num_verts || count <= 65535) {
-r300->emit_draw_elements(r300, indexBuffer, indexSize, minIndex,
- maxIndex, mode, start, count);
+r300->emit_draw_elements(r300, indexBuffer, indexSize, indexBias,
+ minIndex, maxIndex, mode, start, count);
 } else {
 do {
 short_count = MIN2(count, 65534);
-r300->emit_draw_elements(r300, indexBuffer, indexSize, minIndex,
-  maxIndex, mode, start, short_count);
+r300->emit_draw_elements(r300, indexBuffer, indexSize, indexBias,
+ minIndex, maxIndex,
+

Mesa (gallium-index-bias): gallium/docs: Make it clear that minIndex, maxIndex is exclusively a index buffer characteristic.

2010-04-20 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 493a1bb822f80f48cf284cb572acb5dd393a07e1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=493a1bb822f80f48cf284cb572acb5dd393a07e1

Author: José Fonseca 
Date:   Tue Apr 20 10:22:28 2010 +0200

gallium/docs: Make it clear that minIndex, maxIndex is exclusively a index 
buffer characteristic.

Unlike the indexBias which is specific to a draw call.

This are the semantics of both D3D and GL ARB_draw_elements_base_vertex
extension.

---

 src/gallium/docs/source/context.rst |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/gallium/docs/source/context.rst 
b/src/gallium/docs/source/context.rst
index 69e0fcc..c82e681 100644
--- a/src/gallium/docs/source/context.rst
+++ b/src/gallium/docs/source/context.rst
@@ -156,6 +156,9 @@ as indices to fetch vertex attributes.
 ``indexBias`` is a value which is added to every index read from the index 
 buffer before fetching vertex attributes.
 
+``minIndex`` and ``maxIndex`` describe minimum and maximum index contained in
+the index buffer.
+
 If a given vertex element has ``instance_divisor`` set to 0, it is said
 it contains per-vertex data and effective vertex attribute address needs
 to be recalculated for every index.

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


Mesa (gallium-index-bias): draw: Fix typo resulting from bad regular expression in index bias addition.

2010-04-20 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: f1d3f42c47ee0d3c5f13f5b30e6b113d6b542f64
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1d3f42c47ee0d3c5f13f5b30e6b113d6b542f64

Author: José Fonseca 
Date:   Tue Apr 20 10:19:42 2010 +0200

draw: Fix typo resulting from bad regular expression in index bias addition.

---

 src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h 
b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h
index eedd31b..f7a63de 100644
--- a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h
+++ b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h
@@ -78,16 +78,16 @@ static void FUNC( struct draw_pt_front_end *frontend,
 TRIANGLE( vcache,
   DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, 
   get_elt(elts, i + 0) + elt_bias,
-  get_elt(elts, i + 1 + (i&1) + elt_bias),
-  get_elt(elts, i + 2 - (i&1) + elt_bias));
+  get_elt(elts, i + 1 + (i&1)) + elt_bias,
+  get_elt(elts, i + 2 - (i&1)) + elt_bias);
  }
   }
   else {
  for (i = 0; i+2 < count; i++) {
 TRIANGLE( vcache,
   DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, 
-  get_elt(elts, i + 0 + (i&1) + elt_bias),
-  get_elt(elts, i + 1 - (i&1) + elt_bias),
+  get_elt(elts, i + 0 + (i&1)) + elt_bias,
+  get_elt(elts, i + 1 - (i&1)) + elt_bias,
   get_elt(elts, i + 2 ) + elt_bias);
  }
   }

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


Mesa (gallium-index-bias): draw: Fix cache elt_bias implementation.

2010-04-20 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 4e8154e8666ec9375936bbe3fa2ca925ff9be5df
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4e8154e8666ec9375936bbe3fa2ca925ff9be5df

Author: José Fonseca 
Date:   Tue Apr 20 10:32:06 2010 +0200

draw: Fix cache elt_bias implementation.

---

 src/gallium/auxiliary/draw/draw_pt_vcache.c |   13 -
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c 
b/src/gallium/auxiliary/draw/draw_pt_vcache.c
index a513188..28dc514 100644
--- a/src/gallium/auxiliary/draw/draw_pt_vcache.c
+++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c
@@ -347,7 +347,7 @@ vcache_check_run( struct draw_pt_front_end *frontend,
vcache->fetch_max,
draw_count);
   
-   if (max_index >= DRAW_PIPE_MAX_VERTICES ||
+   if (elt_bias + max_index >= DRAW_PIPE_MAX_VERTICES ||
fetch_count >= UNDEFINED_VERTEX_ID ||
fetch_count > draw_count) {
   if (0) debug_printf("fail\n");
@@ -363,6 +363,9 @@ vcache_check_run( struct draw_pt_front_end *frontend,
}
 
 
+   assert((elt_bias >= 0 && min_index + elt_bias >= min_index) ||
+  (elt_bias <  0 && min_index + elt_bias <  min_index));
+
if (elt_bias <= 0 &&
min_index == (unsigned)-elt_bias &&
index_size == 2)
@@ -407,21 +410,21 @@ vcache_check_run( struct draw_pt_front_end *frontend,
  case 1:
 rebase_ubyte_elts( (const ubyte *)elts,
   draw_count,
-  elt_bias - (int)min_index,
+  -elt_bias - (int)min_index,
   storage );
 break;
 
  case 2:
 rebase_ushort_elts( (const ushort *)elts,
draw_count,
-   elt_bias - (int)min_index,
+   -elt_bias - (int)min_index,
storage );
 break;
 
  case 4:
 rebase_uint_elts( (const uint *)elts,
  draw_count,
- elt_bias - (int)min_index,
+ -elt_bias - (int)min_index,
  storage );
 break;
 
@@ -436,7 +439,7 @@ vcache_check_run( struct draw_pt_front_end *frontend,
 
if (fetch_count < UNDEFINED_VERTEX_ID)
   ok = vcache->middle->run_linear_elts( vcache->middle,
-min_index, /* start */
+min_index + elt_bias, /* start */
 fetch_count,
 transformed_elts,
 draw_count );

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


Mesa (gallium-index-bias): draw: No need to rebase for elt_bias.

2010-04-20 Thread Jose Fonseca
Module: Mesa
Branch: gallium-index-bias
Commit: 3dcdca433a5d6cde1c0b4d69ff0aa3a5eee26473
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3dcdca433a5d6cde1c0b4d69ff0aa3a5eee26473

Author: José Fonseca 
Date:   Tue Apr 20 11:06:05 2010 +0200

draw: No need to rebase for elt_bias.

As we are rebasing to min_index + elt_bias, and the vertex buffer has no
elt_bias.

I still don't know how to exercise this code. I hope this is now right.

---

 src/gallium/auxiliary/draw/draw_pt_vcache.c |   12 +---
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c 
b/src/gallium/auxiliary/draw/draw_pt_vcache.c
index 28dc514..37ffbac 100644
--- a/src/gallium/auxiliary/draw/draw_pt_vcache.c
+++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c
@@ -366,8 +366,7 @@ vcache_check_run( struct draw_pt_front_end *frontend,
assert((elt_bias >= 0 && min_index + elt_bias >= min_index) ||
   (elt_bias <  0 && min_index + elt_bias <  min_index));
 
-   if (elt_bias <= 0 &&
-   min_index == (unsigned)-elt_bias &&
+   if (min_index == 0 &&
index_size == 2)
{
   transformed_elts = (const ushort *)elts;
@@ -378,8 +377,7 @@ vcache_check_run( struct draw_pt_front_end *frontend,
   if (!storage)
  goto fail;
   
-  if (elt_bias <= 0 &&
-  min_index == (unsigned)-elt_bias) {
+  if (min_index == 0) {
  switch(index_size) {
  case 1:
 translate_ubyte_elts( (const ubyte *)elts,
@@ -410,21 +408,21 @@ vcache_check_run( struct draw_pt_front_end *frontend,
  case 1:
 rebase_ubyte_elts( (const ubyte *)elts,
   draw_count,
-  -elt_bias - (int)min_index,
+  0 - (int)min_index,
   storage );
 break;
 
  case 2:
 rebase_ushort_elts( (const ushort *)elts,
draw_count,
-   -elt_bias - (int)min_index,
+   0 - (int)min_index,
storage );
 break;
 
  case 4:
 rebase_uint_elts( (const uint *)elts,
  draw_count,
- -elt_bias - (int)min_index,
+ 0 - (int)min_index,
  storage );
 break;
 

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


Mesa (master): 23 new commits

2010-04-20 Thread Jose Fonseca
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a6171a9dd99713266091982215bf1008c9ac8e64
Merge: 49ba607abab17cc07e9f163f5415636474fd7940 
3dcdca433a5d6cde1c0b4d69ff0aa3a5eee26473
Author: José Fonseca 
Date:   Tue Apr 20 11:07:08 2010 +0200

Merge branch 'gallium-index-bias'

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3dcdca433a5d6cde1c0b4d69ff0aa3a5eee26473
Author: José Fonseca 
Date:   Tue Apr 20 11:06:05 2010 +0200

draw: No need to rebase for elt_bias.

As we are rebasing to min_index + elt_bias, and the vertex buffer has no
elt_bias.

I still don't know how to exercise this code. I hope this is now right.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4e8154e8666ec9375936bbe3fa2ca925ff9be5df
Author: José Fonseca 
Date:   Tue Apr 20 10:32:06 2010 +0200

draw: Fix cache elt_bias implementation.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=493a1bb822f80f48cf284cb572acb5dd393a07e1
Author: José Fonseca 
Date:   Tue Apr 20 10:22:28 2010 +0200

gallium/docs: Make it clear that minIndex, maxIndex is exclusively a index 
buffer characteristic.

Unlike the indexBias which is specific to a draw call.

This are the semantics of both D3D and GL ARB_draw_elements_base_vertex
extension.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1d3f42c47ee0d3c5f13f5b30e6b113d6b542f64
Author: José Fonseca 
Date:   Tue Apr 20 10:19:42 2010 +0200

draw: Fix typo resulting from bad regular expression in index bias addition.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dfadf5a579281c6dd4ecdd4ecd5568fbbb1de17e
Author: José Fonseca 
Date:   Mon Apr 19 18:18:45 2010 +0200

r300g: Adapt for index bias interface change.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7c785c0d2c2b5f3ead4b3cf31ad6af02bd90f3a5
Author: José Fonseca 
Date:   Mon Apr 19 18:18:28 2010 +0200

nvfx: Adapt for index bias interface change.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f6f7324bbf03494dc26e266d96919fec6a1f08ba
Author: José Fonseca 
Date:   Mon Apr 19 18:17:45 2010 +0200

nv50: Adapt for index bias interface change.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=583f51ba4bb1029d9d4f338ca3c8f4702abc
Author: José Fonseca 
Date:   Mon Apr 19 18:17:11 2010 +0200

retrace: Support index bias.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=17a43c1718605e4c95bcd7f554b0a5b8293d2578
Author: José Fonseca 
Date:   Mon Apr 19 18:16:57 2010 +0200

mesa/st: Update for index bias interface change.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5620216c984cdbc8983bc1861ebb09380f3467e4
Author: José Fonseca 
Date:   Mon Apr 19 18:16:34 2010 +0200

st/python: Use index bias.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b658580ee2ad33aa9c7438b1efc6c35d6bfab00
Author: José Fonseca 
Date:   Mon Apr 19 18:16:20 2010 +0200

trace: Implement index bias.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9515b78859b52b4532cc9e06366428f2c49c7869
Author: José Fonseca 
Date:   Mon Apr 19 18:16:08 2010 +0200

svga: Implement index bias.

Untested.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=989861fc5ea1792e7ea1be07389db7c3e3b8e383
Author: José Fonseca 
Date:   Mon Apr 19 18:15:39 2010 +0200

softpipe: Implement index bias.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d27a53d46931d2286c90b21ff7f06f44a7a726bc
Author: José Fonseca 
Date:   Mon Apr 19 18:15:11 2010 +0200

llvmpipe: Implement index bias.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=382e9cc07b9193924b0eaf840a4d34cade2c7d92
Author: José Fonseca 
Date:   Mon Apr 19 18:15:05 2010 +0200

identity: Implement index bias.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9ca0f45d8af5aa3152350594093797210d052b6e
Author: José Fonseca 
Date:   Mon Apr 19 18:14:58 2010 +0200

i965g: Implement index bias.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1e7facdd8fbbccbf6f384a4c9bbb394c176f2c4b
Author: José Fonseca 
Date:   Mon Apr 19 18:14:48 2010 +0200

i915: Implement index bias.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8d4638a092d44c0746ff124d3414c20c735e9f6
Author: José Fonseca 
Date:   Mon Apr 19 18:14:35 2010 +0200

failover: Implement index bias.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=150d12679d4d2550e0e54d76a43d153c4254ddfe
Author: José Fonseca 
Date:   Mon Apr 19 18:14:23 2010 +0200

cell: Implement index bias.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2197fac47cb1f87387820678357cc67c9a2536b9
Author: José Fonseca 
Date:   Mon Apr 19 18:14:04 2010 +0200

draw: Implement index bias.

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=857c7c7ca266df4be8d4c725e056f69d4ee96624
Author: José Fonseca 
Date:   Mon Apr 19 15:08:14 2010 +0200

docs: Document indexBias.

URL:
http://cgit.freedesktop.org/mesa/mesa/

Mesa (master): nvfx: Fix typo.

2010-04-20 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: a55ead9d0148348489542adab577d3df0698e86f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a55ead9d0148348489542adab577d3df0698e86f

Author: José Fonseca 
Date:   Tue Apr 20 13:26:36 2010 +0200

nvfx: Fix typo.

---

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

diff --git a/src/gallium/drivers/nvfx/nvfx_draw.c 
b/src/gallium/drivers/nvfx/nvfx_draw.c
index 55b72ac..22cff37 100644
--- a/src/gallium/drivers/nvfx/nvfx_draw.c
+++ b/src/gallium/drivers/nvfx/nvfx_draw.c
@@ -258,7 +258,7 @@ nvfx_draw_elements_swtnl(struct pipe_context *pipe,
map = pipe_buffer_map(pipe, idxbuf,
  PIPE_TRANSFER_READ,
  &ib_transfer);
-   draw_set_mapped_element_buffer(nvfx->draw, idxbuf_size, 
idx_bufbias, map);
+   draw_set_mapped_element_buffer(nvfx->draw, idxbuf_size, 
idxbuf_bias, map);
} else {
draw_set_mapped_element_buffer(nvfx->draw, 0, 0, NULL);
}

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


Mesa (master): draw: Remove draw_vs_llvm.c.

2010-04-20 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 373f03efe70b9fb47dda9955d9c0437dae0edbff
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=373f03efe70b9fb47dda9955d9c0437dae0edbff

Author: José Fonseca 
Date:   Tue Apr 20 13:26:24 2010 +0200

draw: Remove draw_vs_llvm.c.

To silence some warnings.

Super-seeded by Zack's new llvm middle end.

---

 src/gallium/auxiliary/Makefile|1 -
 src/gallium/auxiliary/SConscript  |1 -
 src/gallium/auxiliary/draw/draw_vs.c  |9 +--
 src/gallium/auxiliary/draw/draw_vs.h  |4 -
 src/gallium/auxiliary/draw/draw_vs_llvm.c |  130 -
 5 files changed, 3 insertions(+), 142 deletions(-)

diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index 38ce14d..7d300d4 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -43,7 +43,6 @@ C_SOURCES = \
draw/draw_vs_aos_io.c \
draw/draw_vs_aos_machine.c \
draw/draw_vs_exec.c \
-   draw/draw_vs_llvm.c \
draw/draw_vs_ppc.c \
draw/draw_vs_sse.c \
indices/u_indices_gen.c \
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index a9ec5d4..fc20a8b 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -87,7 +87,6 @@ source = [
 'draw/draw_vs_aos_io.c',
 'draw/draw_vs_aos_machine.c',
 'draw/draw_vs_exec.c',
-'draw/draw_vs_llvm.c',
 'draw/draw_vs_ppc.c',
 'draw/draw_vs_sse.c',
 'draw/draw_vs_varient.c',
diff --git a/src/gallium/auxiliary/draw/draw_vs.c 
b/src/gallium/auxiliary/draw/draw_vs.c
index 9085838..cfd5154 100644
--- a/src/gallium/auxiliary/draw/draw_vs.c
+++ b/src/gallium/auxiliary/draw/draw_vs.c
@@ -91,14 +91,11 @@ draw_create_vertex_shader(struct draw_context *draw,
   tgsi_dump(shader->tokens, 0);
}
 
-   vs = draw_create_vs_llvm( draw, shader );
+   vs = draw_create_vs_sse( draw, shader );
if (!vs) {
-  vs = draw_create_vs_sse( draw, shader );
+  vs = draw_create_vs_ppc( draw, shader );
   if (!vs) {
- vs = draw_create_vs_ppc( draw, shader );
- if (!vs) {
-vs = draw_create_vs_exec( draw, shader );
- }
+ vs = draw_create_vs_exec( draw, shader );
   }
}
 
diff --git a/src/gallium/auxiliary/draw/draw_vs.h 
b/src/gallium/auxiliary/draw/draw_vs.h
index d095c9b..f493323 100644
--- a/src/gallium/auxiliary/draw/draw_vs.h
+++ b/src/gallium/auxiliary/draw/draw_vs.h
@@ -163,10 +163,6 @@ struct draw_vertex_shader *
 draw_create_vs_ppc(struct draw_context *draw,
   const struct pipe_shader_state *templ);
 
-struct draw_vertex_shader *
-draw_create_vs_llvm(struct draw_context *draw,
-   const struct pipe_shader_state *templ);
-
 
 
 struct draw_vs_varient_key;
diff --git a/src/gallium/auxiliary/draw/draw_vs_llvm.c 
b/src/gallium/auxiliary/draw/draw_vs_llvm.c
deleted file mode 100644
index 2a3b6b3..000
--- a/src/gallium/auxiliary/draw/draw_vs_llvm.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * 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, sub license, 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 NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **/
-
- /*
-  * Authors:
-  *   Zack Rusin
-  *   Keith Whitwell 
-  *   Brian Paul
-  */
-
-#include "util/u_memory.h"
-#include "pipe/p_shader_tokens.h"
-#include "draw_private.h"
-#include "draw_context.h"
-#include "draw_vs.h"
-
-#include "tgsi/tgsi_parse.h"
-
-#ifdef HAVE_LLVM
-
-struct draw_llvm_vertex_shader {
-   struct draw_vertex_shader base;
-   struct tgsi_exec_machine *machine;
-};
-
-
-static void
-vs_llvm_prepare( struct draw_vertex_shader *base,
-struct draw_context *draw )
-{
-}
-
-
-static void
-vs_llvm_run_lin

Mesa (master): gallivm: New function to fetch a pixel into a 4xfloat AoS vector.

2010-04-20 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: e08d0cc1651c3c791a3b2947ad829b5b1702c217
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e08d0cc1651c3c791a3b2947ad829b5b1702c217

Author: José Fonseca 
Date:   Tue Apr 20 13:58:45 2010 +0200

gallivm: New function to fetch a pixel into a 4xfloat AoS vector.

---

 src/gallium/auxiliary/gallivm/lp_bld_format.h |   28 +++--
 src/gallium/auxiliary/gallivm/lp_bld_format_aos.c |   32 +
 2 files changed, 50 insertions(+), 10 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format.h 
b/src/gallium/auxiliary/gallivm/lp_bld_format.h
index bb1298e..13d0de8 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format.h
@@ -42,16 +42,9 @@ struct util_format_description;
 struct lp_type;
 
 
-boolean
-lp_format_is_rgba8(const struct util_format_description *desc);
-
-
-void
-lp_build_format_swizzle_soa(const struct util_format_description *format_desc,
-struct lp_type type,
-const LLVMValueRef *unswizzled,
-LLVMValueRef *swizzled);
-
+/*
+ * AoS
+ */
 
 LLVMValueRef
 lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
@@ -71,6 +64,21 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
const struct util_format_description *desc,
LLVMValueRef rgba);
 
+LLVMValueRef
+lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
+const struct util_format_description *format_desc,
+LLVMValueRef ptr);
+
+
+/*
+ * SoA
+ */
+
+void
+lp_build_format_swizzle_soa(const struct util_format_description *format_desc,
+struct lp_type type,
+const LLVMValueRef *unswizzled,
+LLVMValueRef *swizzled);
 
 void
 lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c 
b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
index e55ac6f..4cf285e 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
@@ -378,3 +378,35 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
 
return packed;
 }
+
+
+/**
+ * Fetch a pixel into a 4 float AoS.
+ */
+LLVMValueRef
+lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
+const struct util_format_description *format_desc,
+LLVMValueRef ptr)
+{
+   if (format_desc->layout == UTIL_FORMAT_LAYOUT_PLAIN &&
+   (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
+format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) &&
+   format_desc->block.width == 1 &&
+   format_desc->block.height == 1 &&
+   format_desc->block.bits <= 32 &&
+   format_desc->channel[0].type != UTIL_FORMAT_TYPE_FLOAT)
+   {
+  LLVMValueRef packed;
+
+  ptr = LLVMBuildBitCast(builder, ptr,
+ 
LLVMPointerType(LLVMIntType(format_desc->block.bits), 0) , "");
+
+  packed = LLVMBuildLoad(builder, ptr, "packed");
+
+  return lp_build_unpack_rgba_aos(builder, format_desc, packed);
+   }
+   else {
+  assert(0);
+  return LLVMGetUndef(LLVMVectorType(LLVMFloatType(), 4));
+   }
+}

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


Mesa (master): gallivm: Bring aos format back to life.

2010-04-20 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: b29fcc7b3a043f879da1869cddd68eded1b3b305
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b29fcc7b3a043f879da1869cddd68eded1b3b305

Author: José Fonseca 
Date:   Tue Apr 20 13:41:10 2010 +0200

gallivm: Bring aos format back to life.

Useful for fetching vertices for formats that are straight arrays.

This reverts commit aa364d091e7e2ef2296fb25f92efc79a8c88f77d.

---

 src/gallium/auxiliary/Makefile|1 +
 src/gallium/auxiliary/SConscript  |1 +
 src/gallium/auxiliary/gallivm/lp_bld_format_aos.c |  380 +
 src/gallium/drivers/llvmpipe/Makefile |2 +-
 src/gallium/drivers/llvmpipe/SConscript   |1 +
 src/gallium/drivers/llvmpipe/lp_test_format.c |  314 +
 6 files changed, 698 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index 7d300d4..f8e65cf 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -149,6 +149,7 @@ GALLIVM_SOURCES = \
 gallivm/lp_bld_conv.c \
 gallivm/lp_bld_debug.c \
 gallivm/lp_bld_flow.c \
+gallivm/lp_bld_format_aos.c \
 gallivm/lp_bld_format_soa.c \
 gallivm/lp_bld_init.c \
 gallivm/lp_bld_intr.c \
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index fc20a8b..db3a1e7 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -198,6 +198,7 @@ if env['llvm']:
 'gallivm/lp_bld_conv.c',
 'gallivm/lp_bld_debug.c',
 'gallivm/lp_bld_flow.c',
+'gallivm/lp_bld_format_aos.c',
 'gallivm/lp_bld_format_soa.c',
 'gallivm/lp_bld_intr.c',
 'gallivm/lp_bld_logic.c',
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c 
b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
new file mode 100644
index 000..e55ac6f
--- /dev/null
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
@@ -0,0 +1,380 @@
+/**
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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.
+ *
+ ******/
+
+/**
+ * @file
+ * AoS pixel format manipulation.
+ *
+ * @author Jose Fonseca 
+ */
+
+
+#include "util/u_cpu_detect.h"
+#include "util/u_format.h"
+
+#include "lp_bld_type.h"
+#include "lp_bld_const.h"
+#include "lp_bld_swizzle.h"
+#include "lp_bld_format.h"
+
+
+/**
+ * Unpack a single pixel into its RGBA components.
+ *
+ * @param packed integer.
+ *
+ * @return RGBA in a 4 floats vector.
+ */
+LLVMValueRef
+lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
+ const struct util_format_description *desc,
+ LLVMValueRef packed)
+{
+   LLVMTypeRef type;
+   LLVMValueRef shifted, casted, scaled, masked;
+   LLVMValueRef shifts[4];
+   LLVMValueRef masks[4];
+   LLVMValueRef scales[4];
+   LLVMValueRef swizzles[4];
+   LLVMValueRef aux[4];
+   bool normalized;
+   int empty_channel;
+   unsigned shift;
+   unsigned i;
+
+   /* FIXME: Support more formats */
+   assert(desc->layout == UTIL_FORMAT_LAYOUT_PLAIN);
+   assert(desc->block.width == 1);
+   assert(desc->block.height == 1);
+   assert(desc->block.bits <= 32);
+
+   type = LLVMIntType(desc->block.bits);
+
+   /* Do the intermediate integer computations with 32bit integers since it
+* matches floating point size */
+   if (desc->block.bits < 32)
+  packed = LLVMBuildZExt(builder, packed, LLVMInt32Type(), "");
+
+   /* Broadcast the packed value to a

Mesa (master): draw: Fallback to gallivm for translation of A8R8G8B8/ B8G8R8A8/R10G10B10X2/R10G10B10X2 and other formats.

2010-04-20 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 2cb0a20f67e3f47a96980271e6548318fc8539c1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2cb0a20f67e3f47a96980271e6548318fc8539c1

Author: José Fonseca 
Date:   Tue Apr 20 14:02:05 2010 +0200

draw: Fallback to gallivm for translation of 
A8R8G8B8/B8G8R8A8/R10G10B10X2/R10G10B10X2 and other formats.

These need swizzles, and bitshifts.

---

 src/gallium/auxiliary/draw/draw_llvm_translate.c |   24 ++---
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm_translate.c 
b/src/gallium/auxiliary/draw/draw_llvm_translate.c
index d8438b8..d1c7fa4 100644
--- a/src/gallium/auxiliary/draw/draw_llvm_translate.c
+++ b/src/gallium/auxiliary/draw/draw_llvm_translate.c
@@ -5,9 +5,11 @@
 
 #include "gallivm/lp_bld_arit.h"
 #include "gallivm/lp_bld_struct.h"
+#include "gallivm/lp_bld_format.h"
 #include "gallivm/lp_bld_debug.h"
 
 #include "util/u_memory.h"
+#include "util/u_format.h"
 #include "pipe/p_state.h"
 
 
@@ -408,9 +410,6 @@ struct draw_llvm_translate {
{PIPE_FORMAT_R32G32_FIXED,   from_32_fixed, to_32_fixed, LL_Int32, 2},
{PIPE_FORMAT_R32G32B32_FIXED,from_32_fixed, to_32_fixed, LL_Int32, 3},
{PIPE_FORMAT_R32G32B32A32_FIXED, from_32_fixed, to_32_fixed, LL_Int32, 4},
-
-   {PIPE_FORMAT_A8R8G8B8_UNORM, from_8_unorm, to_8_unorm, LL_Int8, 4},
-   {PIPE_FORMAT_B8G8R8A8_UNORM, from_8_unorm, to_8_unorm, LL_Int8, 4},
 };
 
 
@@ -464,7 +463,14 @@ draw_llvm_translate_from(LLVMBuilderRef builder,
  LLVMValueRef vbuffer,
  enum pipe_format from_format)
 {
+   const struct util_format_description *format_desc;
int i;
+
+   /*
+* The above can only cope with straight arrays: no bitfields,
+* swizzles, or half floats.
+*/
+
for (i = 0; i < Elements(translates); ++i) {
   if (translates[i].format == from_format) {
  /*LLVMTypeRef type = ll_type_to_llvm(translates[i].type);*/
@@ -475,5 +481,15 @@ draw_llvm_translate_from(LLVMBuilderRef builder,
   translates[i].from);
   }
}
-   return LLVMGetUndef(LLVMVectorType(LLVMFloatType(), 4));
+
+
+   /*
+* This doesn't handle anything bigger than 32bits, or half floats
+* yet.
+*
+* TODO: unify all this code into lp_build_fetch_rgba_aos().
+*/
+
+   format_desc = util_format_description(from_format);
+   return lp_build_fetch_rgba_aos(builder, format_desc, vbuffer);
 }

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


Mesa (master): gallivm: Universal format support on lp_build_fetch_rgba_aos via util_format_description ::fetch_rgba_float

2010-04-20 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: ec8d9523d465554e3ffaa1aeef46bfff868281d3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ec8d9523d465554e3ffaa1aeef46bfff868281d3

Author: José Fonseca 
Date:   Tue Apr 20 16:21:08 2010 +0200

gallivm: Universal format support on lp_build_fetch_rgba_aos via 
util_format_description::fetch_rgba_float

This therefore adds support to half float vertex buffers.

---

 src/gallium/auxiliary/draw/draw_llvm_translate.c  |4 +-
 src/gallium/auxiliary/gallivm/lp_bld_format.h |4 +-
 src/gallium/auxiliary/gallivm/lp_bld_format_aos.c |   79 -
 src/gallium/auxiliary/gallivm/lp_bld_format_soa.c |   62 +++--
 src/gallium/drivers/llvmpipe/lp_test_format.c |   80 +
 5 files changed, 125 insertions(+), 104 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm_translate.c 
b/src/gallium/auxiliary/draw/draw_llvm_translate.c
index d1c7fa4..d7da7ed 100644
--- a/src/gallium/auxiliary/draw/draw_llvm_translate.c
+++ b/src/gallium/auxiliary/draw/draw_llvm_translate.c
@@ -464,6 +464,7 @@ draw_llvm_translate_from(LLVMBuilderRef builder,
  enum pipe_format from_format)
 {
const struct util_format_description *format_desc;
+   LLVMValueRef zero;
int i;
 
/*
@@ -491,5 +492,6 @@ draw_llvm_translate_from(LLVMBuilderRef builder,
 */
 
format_desc = util_format_description(from_format);
-   return lp_build_fetch_rgba_aos(builder, format_desc, vbuffer);
+   zero = LLVMConstNull(LLVMInt32Type());
+   return lp_build_fetch_rgba_aos(builder, format_desc, vbuffer, zero, zero);
 }
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format.h 
b/src/gallium/auxiliary/gallivm/lp_bld_format.h
index ecf2cfd..0859375 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format.h
@@ -59,7 +59,9 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
 LLVMValueRef
 lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
 const struct util_format_description *format_desc,
-LLVMValueRef ptr);
+LLVMValueRef ptr,
+LLVMValueRef i,
+LLVMValueRef j);
 
 
 /*
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c 
b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
index 191562d..5cd5b93 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
@@ -34,8 +34,11 @@
 
 
 #include "util/u_format.h"
+#include "util/u_memory.h"
 #include "util/u_math.h"
+#include "util/u_string.h"
 
+#include "lp_bld_init.h"
 #include "lp_bld_type.h"
 #include "lp_bld_const.h"
 #include "lp_bld_swizzle.h"
@@ -295,12 +298,17 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
 
 /**
  * Fetch a pixel into a 4 float AoS.
+ *
+ * i and j are the sub-block pixel coordinates.
  */
 LLVMValueRef
 lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
 const struct util_format_description *format_desc,
-LLVMValueRef ptr)
+LLVMValueRef ptr,
+LLVMValueRef i,
+LLVMValueRef j)
 {
+
if (format_desc->layout == UTIL_FORMAT_LAYOUT_PLAIN &&
(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
 format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) &&
@@ -309,7 +317,9 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
util_is_pot(format_desc->block.bits) &&
format_desc->block.bits <= 32 &&
format_desc->is_bitmask &&
-   !format_desc->is_mixed)
+   !format_desc->is_mixed &&
+   (format_desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED ||
+format_desc->channel[1].type == UTIL_FORMAT_TYPE_UNSIGNED))
{
   LLVMValueRef packed;
 
@@ -321,6 +331,71 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
 
   return lp_build_unpack_rgba_aos(builder, format_desc, packed);
}
+   else if (format_desc->fetch_rgba_float) {
+  /*
+   * Fallback to calling util_format_description::fetch_rgba_float.
+   *
+   * This is definitely not the most efficient way of fetching pixels, as
+   * we miss the opportunity to do vectorization, but this it is a
+   * convenient for formats or scenarios for which there was no opportunity
+   * or incentive to optimize.
+   */
+
+  LLVMModuleRef module = 
LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder)));
+  char name[256];
+  LLVMValueRef function;
+  LLVMValueRef tmp;
+  LLVMValueRef args[4];
+
+  util_snprintf(name, sizeof name, "util_format_%s_fetch_rgba_float",
+format_desc->short_name);
+
+  /*
+   * Declare and bind format_desc->fetch_rgba_float().
+   */
+
+  function = LLVMGetNamedFunction(module, name);
+  if (!function) {
+ LLVMTypeRef ret_type;
+ LLVMTypeRef arg_types[4];

Mesa (master): gallivm: Cleanups and bugfixes to aos format translation.

2010-04-20 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: fe5a483328907776f05b3653421fa565bc07b7ac
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fe5a483328907776f05b3653421fa565bc07b7ac

Author: José Fonseca 
Date:   Tue Apr 20 15:09:02 2010 +0200

gallivm: Cleanups and bugfixes to aos format translation.

---

 src/gallium/auxiliary/gallivm/lp_bld_format.h |8 -
 src/gallium/auxiliary/gallivm/lp_bld_format_aos.c |  156 ---
 src/gallium/drivers/llvmpipe/lp_test_format.c |  221 +
 3 files changed, 126 insertions(+), 259 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format.h 
b/src/gallium/auxiliary/gallivm/lp_bld_format.h
index 13d0de8..ecf2cfd 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format.h
@@ -51,14 +51,6 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
  const struct util_format_description *desc,
  LLVMValueRef packed);
 
-
-LLVMValueRef
-lp_build_unpack_rgba8_aos(LLVMBuilderRef builder,
-  const struct util_format_description *desc,
-  struct lp_type type,
-  LLVMValueRef packed);
-
-
 LLVMValueRef
 lp_build_pack_rgba_aos(LLVMBuilderRef builder,
const struct util_format_description *desc,
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c 
b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
index 4cf285e..191562d 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
@@ -33,8 +33,8 @@
  */
 
 
-#include "util/u_cpu_detect.h"
 #include "util/u_format.h"
+#include "util/u_math.h"
 
 #include "lp_bld_type.h"
 #include "lp_bld_const.h"
@@ -63,10 +63,11 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
LLVMValueRef aux[4];
bool normalized;
int empty_channel;
+   bool needs_uitofp;
unsigned shift;
unsigned i;
 
-   /* FIXME: Support more formats */
+   /* TODO: Support more formats */
assert(desc->layout == UTIL_FORMAT_LAYOUT_PLAIN);
assert(desc->block.width == 1);
assert(desc->block.height == 1);
@@ -93,6 +94,7 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
 
/* Initialize vector constants */
normalized = FALSE;
+   needs_uitofp = FALSE;
empty_channel = -1;
shift = 0;
for (i = 0; i < 4; ++i) {
@@ -105,10 +107,13 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
  empty_channel = i;
   }
   else {
- unsigned mask = (1 << bits) - 1;
+ unsigned long long mask = (1ULL << bits) - 1;
 
  assert(desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED);
- assert(bits < 32);
+
+ if (bits == 32) {
+needs_uitofp = TRUE;
+ }
 
  shifts[i] = LLVMConstInt(LLVMInt32Type(), shift, 0);
  masks[i] = LLVMConstInt(LLVMInt32Type(), mask, 0);
@@ -126,8 +131,12 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
 
shifted = LLVMBuildLShr(builder, packed, LLVMConstVector(shifts, 4), "");
masked = LLVMBuildAnd(builder, shifted, LLVMConstVector(masks, 4), "");
-   /* UIToFP can't be expressed in SSE2 */
-   casted = LLVMBuildSIToFP(builder, masked, LLVMVectorType(LLVMFloatType(), 
4), "");
+   if (!needs_uitofp) {
+  /* UIToFP can't be expressed in SSE2 */
+  casted = LLVMBuildSIToFP(builder, masked, 
LLVMVectorType(LLVMFloatType(), 4), "");
+   } else {
+  casted = LLVMBuildUIToFP(builder, masked, 
LLVMVectorType(LLVMFloatType(), 4), "");
+   }
 
if (normalized)
   scaled = LLVMBuildMul(builder, casted, LLVMConstVector(scales, 4), "");
@@ -138,7 +147,22 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
   aux[i] = LLVMGetUndef(LLVMFloatType());
 
for (i = 0; i < 4; ++i) {
-  enum util_format_swizzle swizzle = desc->swizzle[i];
+  enum util_format_swizzle swizzle;
+
+  if (desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
+ /*
+  * For ZS formats do RGBA = ZZZ1
+  */
+ if (i == 3) {
+swizzle = UTIL_FORMAT_SWIZZLE_1;
+ } else if (desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_NONE) {
+swizzle = UTIL_FORMAT_SWIZZLE_0;
+ } else {
+swizzle = desc->swizzle[0];
+ }
+  } else {
+ swizzle = desc->swizzle[i];
+  }
 
   switch (swizzle) {
   case UTIL_FORMAT_SWIZZLE_X:
@@ -167,117 +191,6 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
 
 
 /**
- * Take a vector with packed pixels and unpack into a rgba8 vector.
- *
- * Formats with bit depth smaller than 32bits are accepted, but they must be
- * padded to 32bits.
- */
-LLVMValueRef
-lp_build_unpack_rgba8_aos(LLVMBuilderRef builder,
-  const struct util_format_description *desc,
-  struct lp_type type,
-  LLVMValueRef packed)
-{
-   struct lp_build_context bld;
-   bool rgba8;
-   LLVMVal

Mesa (master): llvmpipe: Re-enable half float formats.

2010-04-20 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: cc822705e548e1172a550bff25284654500efd81
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cc822705e548e1172a550bff25284654500efd81

Author: José Fonseca 
Date:   Tue Apr 20 16:27:42 2010 +0200

llvmpipe: Re-enable half float formats.

They should be working now, both textures and vertex/index/buffers.

This reverts commit efc69ca61cf8fe7d2d44d177e7737999b6a114b5.

---

 src/gallium/drivers/llvmpipe/lp_screen.c |5 -
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index a30f3c4..6d309c6 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -187,11 +187,6 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
case PIPE_FORMAT_DXT3_RGBA:
case PIPE_FORMAT_DXT5_RGBA:
   return util_format_s3tc_enabled;
-   case PIPE_FORMAT_R16_FLOAT:
-   case PIPE_FORMAT_R16G16_FLOAT:
-   case PIPE_FORMAT_R16G16B16_FLOAT:
-   case PIPE_FORMAT_R16G16B16A16_FLOAT:
-  return FALSE;
default:
   break;
}

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


Mesa (master): mesa/st: Translate a few more mesa/gallium formats.

2010-04-21 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 86d2383e771a4e53bbee2ce0b6f924f0438249b5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=86d2383e771a4e53bbee2ce0b6f924f0438249b5

Author: José Fonseca 
Date:   Wed Apr 21 11:19:39 2010 +0200

mesa/st: Translate a few more mesa/gallium formats.

These endup used by Xvnc.

---

 src/mesa/state_tracker/st_cb_fbo.c |2 ++
 src/mesa/state_tracker/st_format.c |   20 +++-
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_fbo.c 
b/src/mesa/state_tracker/st_cb_fbo.c
index de1b8e7..1ba1fe1 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -230,8 +230,10 @@ st_new_renderbuffer_fb(enum pipe_format format, int 
samples, boolean sw)
strb->software = sw;

switch (format) {
+   case PIPE_FORMAT_R8G8B8A8_UNORM:
case PIPE_FORMAT_B8G8R8A8_UNORM:
case PIPE_FORMAT_A8R8G8B8_UNORM:
+   case PIPE_FORMAT_R8G8B8X8_UNORM:
case PIPE_FORMAT_B8G8R8X8_UNORM:
case PIPE_FORMAT_X8R8G8B8_UNORM:
case PIPE_FORMAT_B5G5R5A1_UNORM:
diff --git a/src/mesa/state_tracker/st_format.c 
b/src/mesa/state_tracker/st_format.c
index 731ec64..8a366d8 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -126,12 +126,18 @@ enum pipe_format
 st_mesa_format_to_pipe_format(gl_format mesaFormat)
 {
switch (mesaFormat) {
-  /* fix this */
-   case MESA_FORMAT_ARGB_REV:
+   case MESA_FORMAT_RGBA:
+  return PIPE_FORMAT_A8B8G8R8_UNORM;
+   case MESA_FORMAT_RGBA_REV:
+  return PIPE_FORMAT_R8G8B8A8_UNORM;
case MESA_FORMAT_ARGB:
   return PIPE_FORMAT_B8G8R8A8_UNORM;
+   case MESA_FORMAT_ARGB_REV:
+  return PIPE_FORMAT_A8R8G8B8_UNORM;
case MESA_FORMAT_XRGB:
   return PIPE_FORMAT_B8G8R8X8_UNORM;
+   case MESA_FORMAT_XRGB_REV:
+  return PIPE_FORMAT_X8R8G8B8_UNORM;
case MESA_FORMAT_ARGB1555:
   return PIPE_FORMAT_B5G5R5A1_UNORM;
case MESA_FORMAT_ARGB:
@@ -190,7 +196,7 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
 #endif
default:
   assert(0);
-  return 0;
+  return PIPE_FORMAT_NONE;
}
 }
 
@@ -202,12 +208,16 @@ gl_format
 st_pipe_format_to_mesa_format(enum pipe_format format)
 {
switch (format) {
+   case PIPE_FORMAT_A8B8G8R8_UNORM:
+  return MESA_FORMAT_RGBA;
+   case PIPE_FORMAT_R8G8B8A8_UNORM:
+  return MESA_FORMAT_RGBA_REV;
case PIPE_FORMAT_B8G8R8A8_UNORM:
   return MESA_FORMAT_ARGB;
-   case PIPE_FORMAT_B8G8R8X8_UNORM:
-  return MESA_FORMAT_XRGB;
case PIPE_FORMAT_A8R8G8B8_UNORM:
   return MESA_FORMAT_ARGB_REV;
+   case PIPE_FORMAT_B8G8R8X8_UNORM:
+  return MESA_FORMAT_XRGB;
case PIPE_FORMAT_X8R8G8B8_UNORM:
   return MESA_FORMAT_XRGB_REV;
case PIPE_FORMAT_B5G5R5A1_UNORM:

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


Mesa (master): draw: Make LLVM integration work without llvmpipe too (e.g. sofptipe).

2010-04-21 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 5c364b3ef78cd36a41c43a771efe5b631ea9559b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5c364b3ef78cd36a41c43a771efe5b631ea9559b

Author: José Fonseca 
Date:   Wed Apr 21 17:30:39 2010 +0100

draw: Make LLVM integration work without llvmpipe too (e.g. sofptipe).

Prevents the assertion failure.

---

 src/gallium/auxiliary/draw/draw_context.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_context.c 
b/src/gallium/auxiliary/draw/draw_context.c
index 710bf79..02abddf 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -49,6 +49,7 @@ struct draw_context *draw_create( struct pipe_context *pipe )
   goto fail;
 
 #if HAVE_LLVM
+   lp_build_init();
assert(lp_build_engine);
draw->engine = lp_build_engine;
 #endif

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


Mesa (master): u_format: Reduce code duplication.

2010-04-22 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 52bc90caa86925629296c02306773c4e00176f78
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=52bc90caa86925629296c02306773c4e00176f78

Author: José Fonseca 
Date:   Thu Apr 22 15:11:34 2010 +0100

u_format: Reduce code duplication.

---

 src/gallium/auxiliary/util/u_format_s3tc.c |  215 +---
 1 files changed, 97 insertions(+), 118 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_format_s3tc.c 
b/src/gallium/auxiliary/util/u_format_s3tc.c
index 79dee2b..abc1951 100644
--- a/src/gallium/auxiliary/util/u_format_s3tc.c
+++ b/src/gallium/auxiliary/util/u_format_s3tc.c
@@ -233,8 +233,12 @@ util_format_dxt5_rgba_fetch_rgba_float(float *dst, const 
uint8_t *src, unsigned
  * Block decompression.
  */
 
-void
-util_format_dxt1_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, 
const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
+static INLINE void
+util_format_dxtn_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+const uint8_t *src_row, unsigned 
src_stride,
+unsigned width, unsigned height,
+util_format_dxtn_fetch_t fetch,
+unsigned block_size)
 {
unsigned x, y, i, j;
for(y = 0; y < height; y += 4) {
@@ -243,98 +247,65 @@ util_format_dxt1_rgb_unpack_rgba_8unorm(uint8_t *dst_row, 
unsigned dst_stride, c
  for(j = 0; j < 4; ++j) {
 for(i = 0; i < 4; ++i) {
uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + 
(x + i)*4;
-   util_format_dxt1_rgb_fetch(0, src, i, j, dst);
+   fetch(0, src, i, j, dst);
 }
  }
- src += 8;
+ src += block_size;
   }
   src_row += src_stride;
}
 }
 
 void
-util_format_dxt1_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned 
dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, 
unsigned height)
+util_format_dxt1_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+const uint8_t *src_row, unsigned 
src_stride,
+unsigned width, unsigned height)
 {
-   unsigned x, y, i, j;
-   for(y = 0; y < height; y += 4) {
-  const uint8_t *src = src_row;
-  for(x = 0; x < width; x += 4) {
- for(j = 0; j < 4; ++j) {
-for(i = 0; i < 4; ++i) {
-   uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + 
(x + i)*4;
-   util_format_dxt1_rgba_fetch(0, src, i, j, dst);
-}
- }
- src += 8;
-  }
-  src_row += src_stride;
-   }
+   util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
+   src_row, src_stride,
+   width, height,
+   util_format_dxt1_rgb_fetch, 8);
 }
 
 void
-util_format_dxt3_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned 
dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, 
unsigned height)
+util_format_dxt1_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned 
src_stride,
+ unsigned width, unsigned height)
 {
-   unsigned x, y, i, j;
-   for(y = 0; y < height; y += 4) {
-  const uint8_t *src = src_row;
-  for(x = 0; x < width; x += 4) {
- for(j = 0; j < 4; ++j) {
-for(i = 0; i < 4; ++i) {
-   uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + 
(x + i)*4;
-   util_format_dxt3_rgba_fetch(0, src, i, j, dst);
-}
- }
- src += 16;
-  }
-  src_row += src_stride;
-   }
+   util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
+   src_row, src_stride,
+   width, height,
+   util_format_dxt1_rgba_fetch, 8);
 }
 
 void
-util_format_dxt5_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned 
dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, 
unsigned height)
+util_format_dxt3_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned 
src_stride,
+ unsigned width, unsigned height)
 {
-   unsigned x, y, i, j;
-   for(y = 0; y < height; y += 4) {
-  const uint8_t *src = src_row;
-  for(x = 0; x < width; x += 4) {
- for(j = 0; j < 4; ++j) {
-for(i = 0; i < 4; ++i) {
-   uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + 
(x + i)*4;
-   util_format_dxt5_rgba_fetch(0, src, i, j, dst);
-}
- }
- 

Mesa (master): llvmpipe: Fix typo in assert.

2010-04-22 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 6ae9975ea08b64d7f4e7a2c6c535c14280bef843
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6ae9975ea08b64d7f4e7a2c6c535c14280bef843

Author: José Fonseca 
Date:   Thu Apr 22 15:11:57 2010 +0100

llvmpipe: Fix typo in assert.

---

 src/gallium/drivers/llvmpipe/lp_state_fs.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 59d5a44..551c375 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -1112,8 +1112,8 @@ make_variant_key(struct llvmpipe_context *lp,
   unsigned chan;
 
   format_desc = util_format_description(lp->framebuffer.cbufs[i]->format);
-  assert(format_desc->layout == UTIL_FORMAT_COLORSPACE_RGB ||
- format_desc->layout == UTIL_FORMAT_COLORSPACE_SRGB);
+  assert(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
+ format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB);
 
   key->blend.rt[i].colormask = lp->blend->rt[i].colormask;
 

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


Mesa (master): llvmpipe: Do not advertise S3TC rendering support.

2010-04-22 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 510669cd87994b39e50a8ab1ac24110e6a299e4d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=510669cd87994b39e50a8ab1ac24110e6a299e4d

Author: José Fonseca 
Date:   Thu Apr 22 15:12:30 2010 +0100

llvmpipe: Do not advertise S3TC rendering support.

---

 src/gallium/drivers/llvmpipe/lp_screen.c |   20 ++--
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index 6d309c6..f453b9f 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -181,16 +181,6 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
   target == PIPE_TEXTURE_3D ||
   target == PIPE_TEXTURE_CUBE);
 
-   switch(format) {
-   case PIPE_FORMAT_DXT1_RGB:
-   case PIPE_FORMAT_DXT1_RGBA:
-   case PIPE_FORMAT_DXT3_RGBA:
-   case PIPE_FORMAT_DXT5_RGBA:
-  return util_format_s3tc_enabled;
-   default:
-  break;
-   }
-
if(tex_usage & PIPE_BIND_RENDER_TARGET) {
   if(format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN)
  return FALSE;
@@ -220,6 +210,16 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
  return FALSE;
}
 
+   switch(format) {
+   case PIPE_FORMAT_DXT1_RGB:
+   case PIPE_FORMAT_DXT1_RGBA:
+   case PIPE_FORMAT_DXT3_RGBA:
+   case PIPE_FORMAT_DXT5_RGBA:
+  return util_format_s3tc_enabled;
+   default:
+  break;
+   }
+
return TRUE;
 }
 

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


Mesa (master): llvmpipe: Fix resource_is_texture.

2010-04-22 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 2eea1714fdffbd665a2076c7b8fed7b264a42968
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2eea1714fdffbd665a2076c7b8fed7b264a42968

Author: José Fonseca 
Date:   Thu Apr 22 18:06:05 2010 +0100

llvmpipe: Fix resource_is_texture.

It was missing PIPE_BIND_RENDER_TARGET, causing assertion failures for
pure render targets.

Also bind flags are too variable and complex for a good assessment for
whether the resource is a texture or not. Target is more concise.

---

 src/gallium/drivers/llvmpipe/lp_texture.c |   20 
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c 
b/src/gallium/drivers/llvmpipe/lp_texture.c
index cee170e..4fce02a 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -55,14 +55,18 @@
 static INLINE boolean
 resource_is_texture(const struct pipe_resource *resource)
 {
-   const unsigned tex_binds = (PIPE_BIND_DISPLAY_TARGET |
-   PIPE_BIND_SCANOUT |
-   PIPE_BIND_SHARED |
-   PIPE_BIND_DEPTH_STENCIL |
-   PIPE_BIND_SAMPLER_VIEW);
-   const struct llvmpipe_resource *lpr = llvmpipe_resource_const(resource);
-
-   return (lpr->base.bind & tex_binds) ? TRUE : FALSE;
+   switch (resource->target) {
+   case PIPE_BUFFER:
+  return FALSE;
+   case PIPE_TEXTURE_1D:
+   case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_3D:
+   case PIPE_TEXTURE_CUBE:
+  return TRUE;
+   default:
+  assert(0);
+  return FALSE;
+   }
 }
 
 

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


Mesa (master): llvmpipe: Use resource_is_texture() consistently.

2010-04-22 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 8bee4c7718a3bd57e3d99f0913d9081cd13fe5fd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8bee4c7718a3bd57e3d99f0913d9081cd13fe5fd

Author: José Fonseca 
Date:   Thu Apr 22 18:22:22 2010 +0100

llvmpipe: Use resource_is_texture() consistently.

Otherwise slightly difference order causes assertion failures.

Also remove mentions of PIPE_BIND_SCANOUT/PIPE_BIND_SHARED. They are not
propoer bind flags and will likely be deprecated. If surfaces should
be passed to the winsys then they should have the DISPLAY_TARGET flag
set, which is a proper bind flag.

---

 src/gallium/drivers/llvmpipe/lp_screen.c  |4 +--
 src/gallium/drivers/llvmpipe/lp_texture.c |   37 +++-
 2 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index f453b9f..7d2cd0c 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -194,9 +194,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
  return FALSE;
}
 
-   if(tex_usage & (PIPE_BIND_DISPLAY_TARGET |
-   PIPE_BIND_SCANOUT |
-   PIPE_BIND_SHARED)) {
+   if(tex_usage & PIPE_BIND_DISPLAY_TARGET) {
   if(!winsys->is_displaytarget_format_supported(winsys, tex_usage, format))
  return FALSE;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c 
b/src/gallium/drivers/llvmpipe/lp_texture.c
index 4fce02a..336a4e4 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -193,20 +193,20 @@ llvmpipe_resource_create(struct pipe_screen *_screen,
 
assert(lpr->base.bind);
 
-   if (lpr->base.bind & (PIPE_BIND_DISPLAY_TARGET |
- PIPE_BIND_SCANOUT |
- PIPE_BIND_SHARED)) {
-  /* displayable surface */
-  if (!llvmpipe_displaytarget_layout(screen, lpr))
- goto fail;
-  assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE);
-   }
-   else if (lpr->base.bind & (PIPE_BIND_SAMPLER_VIEW |
-  PIPE_BIND_DEPTH_STENCIL)) {
-  /* texture map */
-  if (!llvmpipe_texture_layout(screen, lpr))
- goto fail;
-  assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE);
+   if (resource_is_texture(&lpr->base)) {
+  if (lpr->base.bind & PIPE_BIND_DISPLAY_TARGET) {
+ /* displayable surface */
+ if (!llvmpipe_displaytarget_layout(screen, lpr))
+goto fail;
+ assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE);
+  }
+  else {
+ /* texture map */
+ if (!llvmpipe_texture_layout(screen, lpr))
+goto fail;
+ assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE);
+  }
+  assert(lpr->layout[0]);
}
else {
   /* other data (vertex buffer, const buffer, etc) */
@@ -221,10 +221,6 @@ llvmpipe_resource_create(struct pipe_screen *_screen,
  goto fail;
}
 
-   if (resource_is_texture(&lpr->base)) {
-  assert(lpr->layout[0]);
-   }
-
lpr->id = id_counter++;
 
return &lpr->base;
@@ -393,10 +389,7 @@ llvmpipe_resource_data(struct pipe_resource *resource)
 {
struct llvmpipe_resource *lpr = llvmpipe_resource(resource);
 
-   assert((lpr->base.bind & (PIPE_BIND_DISPLAY_TARGET |
- PIPE_BIND_SCANOUT |
- PIPE_BIND_SHARED |
- PIPE_BIND_SAMPLER_VIEW)) == 0);
+   assert(!resource_is_texture(resource));
 
return lpr->data;
 }

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


Mesa (master): llvmpipe: Portability fixes.

2010-04-22 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: cdaceaafee01867d289c2b72fed9c7a200a9e350
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cdaceaafee01867d289c2b72fed9c7a200a9e350

Author: José Fonseca 
Date:   Thu Apr 22 19:24:30 2010 +0100

llvmpipe: Portability fixes.

---

 src/gallium/drivers/llvmpipe/lp_rast.c|4 ++--
 src/gallium/drivers/llvmpipe/lp_texture.c |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c 
b/src/gallium/drivers/llvmpipe/lp_rast.c
index 4046701..0a41b64 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -123,8 +123,8 @@ lp_rast_end( struct lp_rasterizer *rast )
rast->curr_scene = NULL;
 
if (0)
-  printf("Post render scene: tile read: %d  tile write: %d\n",
- tile_read_count, tile_write_count);
+  debug_printf("Post render scene: tile read: %d  tile write: %d\n",
+   tile_read_count, tile_write_count);
 }
 
 
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c 
b/src/gallium/drivers/llvmpipe/lp_texture.c
index f766ab2..336b487 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -85,7 +85,7 @@ alloc_layout_array(unsigned num_slices, unsigned width, 
unsigned height)
assert(LP_TEX_LAYOUT_NONE == 0); /* calloc'ing LP_TEX_LAYOUT_NONE here */
 
return (enum lp_texture_layout *)
-  calloc(num_slices * tx * ty, sizeof(enum lp_texture_layout));
+  CALLOC(num_slices * tx * ty, sizeof(enum lp_texture_layout));
 }
 
 
@@ -265,7 +265,7 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen,
 
   /* free layout flag arrays */
   for (level = 0; level < Elements(lpr->tiled); level++) {
- free(lpr->layout[level]);
+ FREE(lpr->layout[level]);
  lpr->layout[level] = NULL;
   }
}

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


Mesa (master): llvmpipe: Fix rendering to non 32bpp formats.

2010-04-22 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: ccdc6b5913885866e100780bfd661672c9a5d23c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ccdc6b5913885866e100780bfd661672c9a5d23c

Author: José Fonseca 
Date:   Thu Apr 22 19:23:40 2010 +0100

llvmpipe: Fix rendering to non 32bpp formats.

Tiled layout always used 32bpp, therefore linear/tiled strides are not
related.

---

 src/gallium/drivers/llvmpipe/lp_texture.c|   12 
 src/gallium/drivers/llvmpipe/lp_tile_image.c |   22 --
 src/gallium/drivers/llvmpipe/lp_tile_image.h |8 ++--
 3 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c 
b/src/gallium/drivers/llvmpipe/lp_texture.c
index 336a4e4..f766ab2 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -991,14 +991,16 @@ llvmpipe_get_texture_image(struct llvmpipe_resource *lpr,
  x * TILE_SIZE, y * TILE_SIZE,
  TILE_SIZE, TILE_SIZE,
  lpr->base.format,
- lpr->row_stride[level]);
+ lpr->row_stride[level],
+ lpr->tiles_per_row[level]);
}
else {
   lp_tiled_to_linear(other_data, target_data,
  x * TILE_SIZE, y * TILE_SIZE,
  TILE_SIZE, TILE_SIZE,
  lpr->base.format,
- lpr->row_stride[level]);
+ lpr->row_stride[level],
+ lpr->tiles_per_row[level]);
}
 }
 
@@ -1087,7 +1089,8 @@ llvmpipe_get_texture_tile_linear(struct llvmpipe_resource 
*lpr,
if (convert) {
   lp_tiled_to_linear(tiled_image, linear_image,
  x, y, TILE_SIZE, TILE_SIZE, lpr->base.format,
- lpr->row_stride[level]);
+ lpr->row_stride[level],
+ lpr->tiles_per_row[level]);
}
 
if (new_layout != cur_layout)
@@ -1135,7 +1138,8 @@ llvmpipe_get_texture_tile(struct llvmpipe_resource *lpr,
if (convert) {
   lp_linear_to_tiled(linear_image, tiled_image,
  x, y, TILE_SIZE, TILE_SIZE, lpr->base.format,
- lpr->row_stride[level]);
+ lpr->row_stride[level],
+ lpr->tiles_per_row[level]);
}
 
if (new_layout != cur_layout)
diff --git a/src/gallium/drivers/llvmpipe/lp_tile_image.c 
b/src/gallium/drivers/llvmpipe/lp_tile_image.c
index 0852150..af3d157 100644
--- a/src/gallium/drivers/llvmpipe/lp_tile_image.c
+++ b/src/gallium/drivers/llvmpipe/lp_tile_image.c
@@ -122,14 +122,15 @@ tile_4_4_uint16(const uint16_t *src, uint16_t *dst, 
unsigned src_stride)
 
 /**
  * Convert a tiled image into a linear image.
- * \param src_stride  source row stride in bytes (bytes per row of tiles)
  * \param dst_stride  dest row stride in bytes
  */
 void
 lp_tiled_to_linear(const void *src, void *dst,
unsigned x, unsigned y,
unsigned width, unsigned height,
-   enum pipe_format format, unsigned dst_stride)
+   enum pipe_format format,
+   unsigned dst_stride,
+   unsigned tiles_per_row)
 {
assert(x % TILE_SIZE == 0);
assert(y % TILE_SIZE == 0);
@@ -141,9 +142,7 @@ lp_tiled_to_linear(const void *src, void *dst,
 */
if (util_format_is_depth_or_stencil(format)) {
   const uint bpp = util_format_get_blocksize(format);
-  const uint src_stride = dst_stride * TILE_VECTOR_WIDTH;
   const uint tile_w = TILE_VECTOR_WIDTH, tile_h = TILE_VECTOR_HEIGHT;
-  const uint tiles_per_row = src_stride / (tile_w * tile_h * bpp);
 
   dst_stride /= bpp;   /* convert from bytes to words */
 
@@ -191,8 +190,6 @@ lp_tiled_to_linear(const void *src, void *dst,
   const uint bpp = 4;
   const uint tile_w = TILE_SIZE, tile_h = TILE_SIZE;
   const uint bytes_per_tile = tile_w * tile_h * bpp;
-  const uint src_stride = dst_stride * tile_w;
-  const uint tiles_per_row = src_stride / bytes_per_tile;
   uint i, j;
 
   for (j = 0; j < height; j += tile_h) {
@@ -215,13 +212,14 @@ lp_tiled_to_linear(const void *src, void *dst,
 /**
  * Convert a linear image into a tiled image.
  * \param src_stride  source row stride in bytes
- * \param dst_stride  dest row stride in bytes (bytes per row of tiles)
  */
 void
 lp_linear_to_tiled(const void *src, void *dst,
unsigned x, unsigned y,
unsigned width, unsigned height,
-   enum pipe_format format, unsigned src_stride)
+   enum pipe_format format,
+   unsigned src_s

Mesa (master): gallium/docs: Unswap PIPE_BIND_SHARED's comment.

2010-04-22 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: cb384ae8b2028016d66ebf92c9cb2ae3be7d3595
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb384ae8b2028016d66ebf92c9cb2ae3be7d3595

Author: José Fonseca 
Date:   Thu Apr 22 19:51:10 2010 +0100

gallium/docs: Unswap PIPE_BIND_SHARED's comment.

---

 src/gallium/docs/source/screen.rst |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/gallium/docs/source/screen.rst 
b/src/gallium/docs/source/screen.rst
index 05688cc..c5815f8 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -121,8 +121,8 @@ resources might be created and handled quite differently.
 * ``PIPE_BIND_DEPTH_STENCIL``: A depth (Z) buffer and/or stencil buffer. Any
   depth/stencil surface/resource attached to pipe_framebuffer_state::zsbuf must
   have this flag set.
-* ``PIPE_BIND_DISPLAY_TARGET``: A sharable buffer that can be given to another
-  process.
+* ``PIPE_BIND_DISPLAY_TARGET``: A surface that can be presented to screen. 
Arguments to
+  pipe_screen::flush_front_buffer must have this flag set.
 * ``PIPE_BIND_SAMPLER_VIEW``: A texture that may be sampled from in a fragment
   or vertex shader.
 * ``PIPE_BIND_VERTEX_BUFFER``: A vertex buffer.
@@ -135,7 +135,8 @@ resources might be created and handled quite differently.
 * ``PIPE_BIND_TRANSFER_READ``: A transfer object which will be read from.
 * ``PIPE_BIND_CUSTOM``:
 * ``PIPE_BIND_SCANOUT``: A front color buffer or scanout buffer.
-* ``PIPE_BIND_SHARED``:
+* ``PIPE_BIND_SHARED``: A sharable buffer that can be given to another
+  process.
 
 .. _pipe_usage:
 

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


Mesa (master): llvmpipe: Undo zs tiling changes.

2010-04-22 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: c059565054e80bd6306e1c3a2c7b85ef33082d9f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c059565054e80bd6306e1c3a2c7b85ef33082d9f

Author: José Fonseca 
Date:   Thu Apr 22 20:38:36 2010 +0100

llvmpipe: Undo zs tiling changes.

tile_w/tile_h have different meaning there.

This partialy reverts commit ccdc6b5913885866e100780bfd661672c9a5d23c.

---

 src/gallium/drivers/llvmpipe/lp_tile_image.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_tile_image.c 
b/src/gallium/drivers/llvmpipe/lp_tile_image.c
index af3d157..7a2cc3e 100644
--- a/src/gallium/drivers/llvmpipe/lp_tile_image.c
+++ b/src/gallium/drivers/llvmpipe/lp_tile_image.c
@@ -142,7 +142,9 @@ lp_tiled_to_linear(const void *src, void *dst,
 */
if (util_format_is_depth_or_stencil(format)) {
   const uint bpp = util_format_get_blocksize(format);
+  const uint src_stride = dst_stride * TILE_VECTOR_WIDTH;
   const uint tile_w = TILE_VECTOR_WIDTH, tile_h = TILE_VECTOR_HEIGHT;
+  const uint tiles_per_row = src_stride / (tile_w * tile_h * bpp);
 
   dst_stride /= bpp;   /* convert from bytes to words */
 
@@ -230,7 +232,9 @@ lp_linear_to_tiled(const void *src, void *dst,
 
if (util_format_is_depth_or_stencil(format)) {
   const uint bpp = util_format_get_blocksize(format);
+  const uint dst_stride = src_stride * TILE_VECTOR_WIDTH;
   const uint tile_w = TILE_VECTOR_WIDTH, tile_h = TILE_VECTOR_HEIGHT;
+  const uint tiles_per_row = dst_stride / (tile_w * tile_h * bpp);
 
   src_stride /= bpp;   /* convert from bytes to words */
 

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


Mesa (master): softpipe: YUV textures should be supported.

2010-04-23 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: d7996beb4ca01ba9ca83e71d2833278cb4df3a75
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d7996beb4ca01ba9ca83e71d2833278cb4df3a75

Author: José Fonseca 
Date:   Fri Apr 23 17:04:06 2010 +0100

softpipe: YUV textures should be supported.

---

 src/gallium/drivers/softpipe/sp_screen.c |4 
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_screen.c 
b/src/gallium/drivers/softpipe/sp_screen.c
index 7b1e058..52ccb32 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -155,10 +155,6 @@ softpipe_is_format_supported( struct pipe_screen *screen,
   target == PIPE_TEXTURE_CUBE);
 
switch(format) {
-   case PIPE_FORMAT_YUYV:
-   case PIPE_FORMAT_UYVY:
-  return FALSE;
-
case PIPE_FORMAT_DXT1_RGB:
case PIPE_FORMAT_DXT1_RGBA:
case PIPE_FORMAT_DXT3_RGBA:

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


Mesa (master): sw/xlib: Fallback to XPutImage when shmget fails.

2010-04-23 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 405f925d4e5fa74961754af93e7fb309774551cc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=405f925d4e5fa74961754af93e7fb309774551cc

Author: José Fonseca 
Date:   Fri Apr 23 16:56:55 2010 +0100

sw/xlib: Fallback to XPutImage when shmget fails.

After continuously running regression tests on Ubuntu for 2 days, shmget
mysteriously starts to fail. Even when the X server is reset.

This allow rendering to proceed, albeit using a slower presentation path.

---

 src/gallium/winsys/sw/xlib/xlib_sw_winsys.c |   11 +--
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c 
b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
index ec4f919..278a191 100644
--- a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
+++ b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
@@ -385,13 +385,12 @@ xm_displaytarget_create(struct sw_winsys *winsys,
 
if (!debug_get_bool_option("XLIB_NO_SHM", FALSE))
{
-  xm_dt->shminfo.shmid = -1;
-  xm_dt->shminfo.shmaddr = (char *) -1;
-  xm_dt->shm = TRUE;
- 
   xm_dt->data = alloc_shm(xm_dt, size);
-  if(!xm_dt->data)
- goto no_data;
+  if(!xm_dt->data) {
+ xm_dt->shminfo.shmid = -1;
+ xm_dt->shminfo.shmaddr = (char *) -1;
+ xm_dt->shm = TRUE;
+  }
}
 
if(!xm_dt->data) {

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


Mesa (master): mesa/st: Remove dead members.

2010-04-23 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 99bee1570bc23d8070c7ac3da67e46bdb2e6ec0d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=99bee1570bc23d8070c7ac3da67e46bdb2e6ec0d

Author: José Fonseca 
Date:   Fri Apr 23 17:03:10 2010 +0100

mesa/st: Remove dead members.

---

 src/mesa/state_tracker/st_context.h |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/mesa/state_tracker/st_context.h 
b/src/mesa/state_tracker/st_context.h
index dfee490..3637f6e 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -201,7 +201,6 @@ struct st_framebuffer
 {
GLframebuffer Base;
void *Private;
-   GLuint InitWidth, InitHeight;
 
struct st_framebuffer_iface *iface;
enum st_attachment_type statts[ST_ATTACHMENT_COUNT];

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


Mesa (master): st/xlib: Try to propagate failure to create framebuffer.

2010-04-23 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: f73feb9cd6095d82b87e7022c351408e6e232797
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f73feb9cd6095d82b87e7022c351408e6e232797

Author: José Fonseca 
Date:   Fri Apr 23 17:07:14 2010 +0100

st/xlib: Try to propagate failure to create framebuffer.

Doesn't help much, since it is ignored by st_framebuffer_validate.

---

 src/gallium/state_trackers/glx/xlib/xm_st.c |   13 ++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c 
b/src/gallium/state_trackers/glx/xlib/xm_st.c
index 294b593..1c678b4 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_st.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_st.c
@@ -125,7 +125,7 @@ xmesa_st_framebuffer_copy_textures(struct 
st_framebuffer_iface *stfbi,
 /**
  * Remove outdated textures and create the requested ones.
  */
-static void
+static boolean
 xmesa_st_framebuffer_validate_textures(struct st_framebuffer_iface *stfbi,
unsigned width, unsigned height,
unsigned mask)
@@ -183,12 +183,16 @@ xmesa_st_framebuffer_validate_textures(struct 
st_framebuffer_iface *stfbi,
 
  xstfb->textures[i] =
 xstfb->screen->resource_create(xstfb->screen, &templ);
+ if (!xstfb->textures[i])
+return FALSE;
   }
}
 
xstfb->texture_width = width;
xstfb->texture_height = height;
xstfb->texture_mask = mask;
+
+   return TRUE;
 }
 
 static boolean 
@@ -200,6 +204,7 @@ xmesa_st_framebuffer_validate(struct st_framebuffer_iface 
*stfbi,
struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
unsigned statt_mask, new_mask, i;
boolean resized;
+   boolean ret;
 
statt_mask = 0x0;
for (i = 0; i < count; i++)
@@ -212,8 +217,10 @@ xmesa_st_framebuffer_validate(struct st_framebuffer_iface 
*stfbi,
 
/* revalidate textures */
if (resized || new_mask) {
-  xmesa_st_framebuffer_validate_textures(stfbi,
-xstfb->buffer->width, xstfb->buffer->height, statt_mask);
+  ret = xmesa_st_framebuffer_validate_textures(stfbi,
+  xstfb->buffer->width, xstfb->buffer->height, statt_mask);
+  if (!ret)
+ return ret;
 
   if (!resized) {
  enum st_attachment_type back, front;

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


Mesa (master): gallium: s/free/FREE/ and same for friends.

2010-04-23 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 2ce1d6696b1415fcc340bcf888904e43c2792c68
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ce1d6696b1415fcc340bcf888904e43c2792c68

Author: José Fonseca 
Date:   Fri Apr 23 21:52:44 2010 +0100

gallium: s/free/FREE/ and same for friends.

Based on Stephen Johnson's feedback.

---

 src/gallium/auxiliary/util/u_surfaces.c |2 +-
 src/gallium/drivers/failover/fo_context.c   |2 +-
 src/gallium/drivers/failover/fo_state.c |   32 +-
 src/gallium/drivers/i965/brw_curbe.c|2 +-
 src/gallium/drivers/i965/brw_state_batch.c  |4 +-
 src/gallium/drivers/identity/id_context.c   |6 ++--
 src/gallium/drivers/identity/id_drm.c   |2 +-
 src/gallium/drivers/llvmpipe/lp_scene.c |2 +-
 src/gallium/drivers/trace/tr_context.c  |4 +-
 src/gallium/drivers/trace/tr_drm.c  |2 +-
 src/gallium/winsys/i915/sw/i915_sw_buffer.c |2 +-
 11 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_surfaces.c 
b/src/gallium/auxiliary/util/u_surfaces.c
index 0be4609..0248120 100644
--- a/src/gallium/auxiliary/util/u_surfaces.c
+++ b/src/gallium/auxiliary/util/u_surfaces.c
@@ -105,7 +105,7 @@ util_surfaces_destroy(struct util_surfaces *us, struct 
pipe_resource *pt, void (
if(ps)
   destroy_surface(ps);
 }
-free(us->u.array);
+FREE(us->u.array);
 us->u.array = NULL;
   }
}
diff --git a/src/gallium/drivers/failover/fo_context.c 
b/src/gallium/drivers/failover/fo_context.c
index 236c50f..9515cd8 100644
--- a/src/gallium/drivers/failover/fo_context.c
+++ b/src/gallium/drivers/failover/fo_context.c
@@ -39,7 +39,7 @@ static void failover_destroy( struct pipe_context *pipe )
 {
struct failover_context *failover = failover_context( pipe );
 
-   free( failover );
+   FREE( failover );
 }
 
 
diff --git a/src/gallium/drivers/failover/fo_state.c 
b/src/gallium/drivers/failover/fo_state.c
index b682ce6..ff6c59f 100644
--- a/src/gallium/drivers/failover/fo_state.c
+++ b/src/gallium/drivers/failover/fo_state.c
@@ -53,7 +53,7 @@ static void *
 failover_create_blend_state( struct pipe_context *pipe,
  const struct pipe_blend_state *blend )
 {
-   struct fo_state *state = malloc(sizeof(struct fo_state));
+   struct fo_state *state = MALLOC(sizeof(struct fo_state));
struct failover_context *failover = failover_context(pipe);
 
state->sw_state = failover->sw->create_blend_state(failover->sw, blend);
@@ -85,7 +85,7 @@ failover_delete_blend_state( struct pipe_context *pipe,
failover->hw->delete_blend_state(failover->hw, state->hw_state);
state->sw_state = 0;
state->hw_state = 0;
-   free(state);
+   FREE(state);
 }
 
 static void
@@ -129,7 +129,7 @@ static void *
 failover_create_depth_stencil_state(struct pipe_context *pipe,
   const struct pipe_depth_stencil_alpha_state 
*templ)
 {
-   struct fo_state *state = malloc(sizeof(struct fo_state));
+   struct fo_state *state = MALLOC(sizeof(struct fo_state));
struct failover_context *failover = failover_context(pipe);
 
state->sw_state = 
failover->sw->create_depth_stencil_alpha_state(failover->sw, templ);
@@ -161,7 +161,7 @@ failover_delete_depth_stencil_state(struct pipe_context 
*pipe,
failover->hw->delete_depth_stencil_alpha_state(failover->hw, 
state->hw_state);
state->sw_state = 0;
state->hw_state = 0;
-   free(state);
+   FREE(state);
 }
 
 static void
@@ -181,7 +181,7 @@ static void *
 failover_create_fs_state(struct pipe_context *pipe,
  const struct pipe_shader_state *templ)
 {
-   struct fo_state *state = malloc(sizeof(struct fo_state));
+   struct fo_state *state = MALLOC(sizeof(struct fo_state));
struct failover_context *failover = failover_context(pipe);
 
state->sw_state = failover->sw->create_fs_state(failover->sw, templ);
@@ -212,14 +212,14 @@ failover_delete_fs_state(struct pipe_context *pipe,
failover->hw->delete_fs_state(failover->hw, state->hw_state);
state->sw_state = 0;
state->hw_state = 0;
-   free(state);
+   FREE(state);
 }
 
 static void *
 failover_create_vs_state(struct pipe_context *pipe,
  const struct pipe_shader_state *templ)
 {
-   struct fo_state *state = malloc(sizeof(struct fo_state));
+   struct fo_state *state = MALLOC(sizeof(struct fo_state));
struct failover_context *failover = failover_context(pipe);
 
state->sw_state = failover->sw->create_vs_state(failover->sw, templ);
@@ -252,7 +252,7 @@ failover_delete_vs_state(struct pipe_context *pipe,
failover->hw->delete_vs_state(failover->hw, state->hw_state);
state->sw_state = 0;
state->hw_state = 0;
-   free(state);
+   FREE(state);
 }
 
 
@@ -262,7 +262,7 @@ failover_create_vertex_elements_state( struct pipe_context 
*pipe,
unsigned count,
 

Mesa (master): gallivm: LLVMConstBitCast -> LLVMBuildBitCast

2010-04-24 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 35a920e83b2e85f1180d9c0a752ef917f2e08416
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=35a920e83b2e85f1180d9c0a752ef917f2e08416

Author: José Fonseca 
Date:   Sat Apr 24 09:58:41 2010 +0100

gallivm: LLVMConstBitCast -> LLVMBuildBitCast

As the argument in general might not be a constant.

---

 src/gallium/auxiliary/gallivm/lp_bld_arit.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c 
b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
index d696763..5f9d4c6 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
@@ -1503,7 +1503,7 @@ lp_build_log2_approx(struct lp_build_context *bld,
}
 
if(p_exp) {
-  exp = LLVMConstBitCast(exp, vec_type);
+  exp = LLVMBuildBitCast(bld->builder, exp, vec_type, "");
   *p_exp = exp;
}
 
@@ -1575,8 +1575,10 @@ lp_build_float_log2_approx(struct lp_build_context *bld,
   res = LLVMBuildAdd(bld->builder, logmant, logexp, "");
}
 
-   if(p_exp)
+   if(p_exp) {
+  exp = LLVMBuildBitCast(bld->builder, exp, float_type, "");
   *p_exp = exp;
+   }
 
if(p_floor_log2)
   *p_floor_log2 = logexp;

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


Mesa (master): sw/xlib: Fix bad logic in shm allocation.

2010-04-24 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 94b04d3d1ccd1b717dbc9d797341f1170121645a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=94b04d3d1ccd1b717dbc9d797341f1170121645a

Author: José Fonseca 
Date:   Sat Apr 24 10:15:09 2010 +0100

sw/xlib: Fix bad logic in shm allocation.

Fixes fdo 27823.

---

 src/gallium/winsys/sw/xlib/xlib_sw_winsys.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c 
b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
index 7df7416..56d2df8 100644
--- a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
+++ b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
@@ -124,6 +124,9 @@ static char *alloc_shm(struct xm_displaytarget *buf, 
unsigned size)
 {
XShmSegmentInfo *const shminfo = & buf->shminfo;
 
+   shminfo->shmid = -1;
+   shminfo->shmaddr = (char *) -1;
+
shminfo->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777);
if (shminfo->shmid < 0) {
   return NULL;
@@ -385,12 +388,9 @@ xm_displaytarget_create(struct sw_winsys *winsys,
xm_dt->stride = align(util_format_get_stride(format, width), alignment);
size = xm_dt->stride * nblocksy;
 
-   if (!debug_get_option_xlib_no_shm())
-   {
+   if (!debug_get_option_xlib_no_shm()) {
   xm_dt->data = alloc_shm(xm_dt, size);
-  if(!xm_dt->data) {
- xm_dt->shminfo.shmid = -1;
- xm_dt->shminfo.shmaddr = (char *) -1;
+  if (xm_dt->data) {
  xm_dt->shm = TRUE;
   }
}

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


Mesa (master): cso_cache: Ensure irrelevant state of the blend state is zeroed.

2010-04-24 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 53499c64b212c68527f84f5e672cdfc95935f643
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=53499c64b212c68527f84f5e672cdfc95935f643

Author: José Fonseca 
Date:   Sat Apr 24 10:33:44 2010 +0100

cso_cache: Ensure irrelevant state of the blend state is zeroed.

Otherwise drivers that bake the full blend state in a key end up having
uninitialized memory in their key.

Courtesy of valgrind.

---

 src/gallium/auxiliary/cso_cache/cso_context.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index 6fd4bd3..6d0b420 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -349,6 +349,7 @@ enum pipe_error cso_set_blend(struct cso_context *ctx,
   if (!cso)
  return PIPE_ERROR_OUT_OF_MEMORY;
 
+  memset(&cso->state, 0, sizeof cso->state);
   memcpy(&cso->state, templ, key_size);
   cso->data = ctx->pipe->create_blend_state(ctx->pipe, &cso->state);
   cso->delete_state = (cso_state_callback)ctx->pipe->delete_blend_state;

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


Mesa (master): svga: Translate recently added vertex formats.

2010-04-24 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: e6c3f594e904256b031092ff4f1a321a005f53de
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e6c3f594e904256b031092ff4f1a321a005f53de

Author: José Fonseca 
Date:   Sat Apr 24 11:34:22 2010 +0100

svga: Translate recently added vertex formats.

---

 src/gallium/drivers/svga/svga_state_need_swtnl.c |8 ++--
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c 
b/src/gallium/drivers/svga/svga_state_need_swtnl.c
index dfaab53..c8ea749 100644
--- a/src/gallium/drivers/svga/svga_state_need_swtnl.c
+++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c
@@ -52,14 +52,10 @@ svga_translate_vertex_format(enum pipe_format format)
case PIPE_FORMAT_R16G16B16A16_SNORM:   return SVGA3D_DECLTYPE_SHORT4N;
case PIPE_FORMAT_R16G16_UNORM: return SVGA3D_DECLTYPE_USHORT2N;
case PIPE_FORMAT_R16G16B16A16_UNORM:   return SVGA3D_DECLTYPE_USHORT4N;
-
-   /* These formats don't exist yet:
-* 
-   case PIPE_FORMAT_R10G10B10_USCALED:return SVGA3D_DECLTYPE_UDEC3;
-   case PIPE_FORMAT_R10G10B10_SNORM:  return SVGA3D_DECLTYPE_DEC3N;
+   case PIPE_FORMAT_R10G10B10X2_USCALED:  return SVGA3D_DECLTYPE_UDEC3;
+   case PIPE_FORMAT_R10G10B10X2_SNORM:return SVGA3D_DECLTYPE_DEC3N;
case PIPE_FORMAT_R16G16_FLOAT: return SVGA3D_DECLTYPE_FLOAT16_2;
case PIPE_FORMAT_R16G16B16A16_FLOAT:   return SVGA3D_DECLTYPE_FLOAT16_4;
-   */
 
default:
   /* There are many formats without hardware support.  This case

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


Mesa (master): svga: D3DCOLOR actually stands for B8G8R8A8.

2010-04-24 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: e94a092437d3c2ebe2a4c514cc1e3fce38c1d7e9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e94a092437d3c2ebe2a4c514cc1e3fce38c1d7e9

Author: José Fonseca 
Date:   Sat Apr 24 11:38:41 2010 +0100

svga: D3DCOLOR actually stands for B8G8R8A8.

---

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

diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c 
b/src/gallium/drivers/svga/svga_state_need_swtnl.c
index c8ea749..d34d68f 100644
--- a/src/gallium/drivers/svga/svga_state_need_swtnl.c
+++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c
@@ -43,7 +43,7 @@ svga_translate_vertex_format(enum pipe_format format)
case PIPE_FORMAT_R32G32_FLOAT: return SVGA3D_DECLTYPE_FLOAT2;
case PIPE_FORMAT_R32G32B32_FLOAT:  return SVGA3D_DECLTYPE_FLOAT3;
case PIPE_FORMAT_R32G32B32A32_FLOAT:   return SVGA3D_DECLTYPE_FLOAT4;
-   case PIPE_FORMAT_A8R8G8B8_UNORM:   return SVGA3D_DECLTYPE_D3DCOLOR;
+   case PIPE_FORMAT_B8G8R8A8_UNORM:   return SVGA3D_DECLTYPE_D3DCOLOR;
case PIPE_FORMAT_R8G8B8A8_USCALED: return SVGA3D_DECLTYPE_UBYTE4;
case PIPE_FORMAT_R16G16_SSCALED:   return SVGA3D_DECLTYPE_SHORT2;
case PIPE_FORMAT_R16G16B16A16_SSCALED: return SVGA3D_DECLTYPE_SHORT4;

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


Mesa (master): llvmpipe: Pass flatshade_first to setup.

2010-04-24 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 30a1c36dc85f0928a9adb69630c418f9aabbdd98
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=30a1c36dc85f0928a9adb69630c418f9aabbdd98

Author: José Fonseca 
Date:   Sat Apr 24 12:00:06 2010 +0100

llvmpipe: Pass flatshade_first to setup.

Fixes piglit provoking-vertex.

---

 src/gallium/drivers/llvmpipe/lp_state_rasterizer.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c 
b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
index 47f65fe..3fba5e4 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
@@ -71,6 +71,8 @@ llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, 
void *handle)
llvmpipe->rasterizer->front_winding == PIPE_WINDING_CCW,
llvmpipe->rasterizer->scissor,
llvmpipe->rasterizer->gl_rasterization_rules);
+  lp_setup_set_flatshade_first( llvmpipe->setup,
+   llvmpipe->rasterizer->flatshade_first);
}
 
llvmpipe->dirty |= LP_NEW_RASTERIZER;

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


Mesa (master): llvmpipe: Move the determination of the number of threads to the screen.

2010-04-24 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 39be50dcdebe6bcbb48cb6aa8ac151eee811acb1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=39be50dcdebe6bcbb48cb6aa8ac151eee811acb1

Author: José Fonseca 
Date:   Sat Apr 24 13:20:39 2010 +0100

llvmpipe: Move the determination of the number of threads to the screen.

---

 src/gallium/drivers/llvmpipe/lp_limits.h|3 +++
 src/gallium/drivers/llvmpipe/lp_rast.c  |   18 +++---
 src/gallium/drivers/llvmpipe/lp_rast.h  |2 +-
 src/gallium/drivers/llvmpipe/lp_rast_priv.h |8 +++-
 src/gallium/drivers/llvmpipe/lp_screen.c|   21 +++--
 src/gallium/drivers/llvmpipe/lp_screen.h|2 ++
 src/gallium/drivers/llvmpipe/lp_setup.c |6 --
 src/gallium/drivers/llvmpipe/lp_setup_context.h |1 +
 8 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_limits.h 
b/src/gallium/drivers/llvmpipe/lp_limits.h
index 9ab1b4b..c7c5a1e 100644
--- a/src/gallium/drivers/llvmpipe/lp_limits.h
+++ b/src/gallium/drivers/llvmpipe/lp_limits.h
@@ -58,4 +58,7 @@
 #define LP_MAX_WIDTH  (1 << (LP_MAX_TEXTURE_LEVELS - 1))
 
 
+#define LP_MAX_THREADS 8
+
+
 #endif /* LP_LIMITS_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c 
b/src/gallium/drivers/llvmpipe/lp_rast.c
index 0a41b64..c3e186b 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -869,20 +869,6 @@ create_rast_threads(struct lp_rasterizer *rast)
 {
unsigned i;
 
-#ifdef PIPE_OS_WINDOWS
-   /* Multithreading not supported on windows until conditions and barriers are
-* properly implemented. */
-   rast->num_threads = 0;
-#else
-#ifdef PIPE_OS_EMBEDDED
-   rast->num_threads = 0;
-#else
-   rast->num_threads = util_cpu_caps.nr_cpus;
-#endif
-   rast->num_threads = debug_get_num_option("LP_NUM_THREADS", 
rast->num_threads);
-   rast->num_threads = MIN2(rast->num_threads, MAX_THREADS);
-#endif
-
/* NOTE: if num_threads is zero, we won't use any threads */
for (i = 0; i < rast->num_threads; i++) {
   pipe_semaphore_init(&rast->tasks[i].work_ready, 0);
@@ -900,7 +886,7 @@ create_rast_threads(struct lp_rasterizer *rast)
  *   processing them.
  */
 struct lp_rasterizer *
-lp_rast_create( void )
+lp_rast_create( unsigned num_threads )
 {
struct lp_rasterizer *rast;
unsigned i;
@@ -917,6 +903,8 @@ lp_rast_create( void )
   task->thread_index = i;
}
 
+   rast->num_threads = num_threads;
+
create_rast_threads(rast);
 
/* for synchronizing rasterization threads */
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h 
b/src/gallium/drivers/llvmpipe/lp_rast.h
index a0ecb2f..e2f6f92 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast.h
@@ -134,7 +134,7 @@ struct lp_rast_triangle {
 
 
 struct lp_rasterizer *
-lp_rast_create( void );
+lp_rast_create( unsigned num_threads );
 
 void
 lp_rast_destroy( struct lp_rasterizer * );
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h 
b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
index 8bf2b92..18457ff 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
@@ -35,9 +35,7 @@
 #include "lp_scene.h"
 #include "lp_texture.h"
 #include "lp_tile_soa.h"
-
-
-#define MAX_THREADS 8  /* XXX probably temporary here */
+#include "lp_limits.h"
 
 
 struct lp_rasterizer;
@@ -113,10 +111,10 @@ struct lp_rasterizer
struct lp_scene *curr_scene;
 
/** A task object for each rasterization thread */
-   struct lp_rasterizer_task tasks[MAX_THREADS];
+   struct lp_rasterizer_task tasks[LP_MAX_THREADS];
 
unsigned num_threads;
-   pipe_thread threads[MAX_THREADS];
+   pipe_thread threads[LP_MAX_THREADS];
 
/** For synchronizing the rasterization threads */
pipe_barrier barrier;
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index 7d2cd0c..88c0604 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -27,6 +27,8 @@
 
 
 #include "util/u_memory.h"
+#include "util/u_math.h"
+#include "util/u_cpu_detect.h"
 #include "util/u_format.h"
 #include "util/u_format_s3tc.h"
 #include "pipe/p_defines.h"
@@ -39,6 +41,7 @@
 #include "lp_context.h"
 #include "lp_debug.h"
 #include "lp_public.h"
+#include "lp_limits.h"
 
 #include "state_tracker/sw_winsys.h"
 
@@ -284,12 +287,26 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
screen->base.context_create = llvmpipe_create_context;
screen->base.flush_frontbuffer = llvmpipe_flush_frontbuffer;
 
-   util_format_s3tc_init();
-
llvmpipe_init_screen_resource_funcs(&screen->base);
llvmpipe_init_screen_fence_funcs(&screen->base);
 
lp_jit_screen_init(screen);
 
+#ifdef PIPE_OS_WINDOWS
+   /* Multithreading not supported on windows until conditions and barriers are
+* properly implemented. */
+   screen->num_threads = 0;
+

Mesa (master): gallivm: Centralize the cpu caps detection.

2010-04-24 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: e7a8cfc8776c70f8c4cc3e158f663f6c630169ed
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e7a8cfc8776c70f8c4cc3e158f663f6c630169ed

Author: José Fonseca 
Date:   Sat Apr 24 13:19:10 2010 +0100

gallivm: Centralize the cpu caps detection.

---

 src/gallium/auxiliary/gallivm/lp_bld_init.c |   10 ++
 src/gallium/drivers/llvmpipe/lp_jit.c   |9 -
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c 
b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index de07c22..5067d0a 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -27,6 +27,7 @@
 
 
 #include "pipe/p_compiler.h"
+#include "util/u_cpu_detect.h"
 #include "util/u_debug.h"
 #include "lp_bld_init.h"
 
@@ -62,6 +63,15 @@ lp_build_init(void)
 
if (!lp_build_target)
   lp_build_target = LLVMGetExecutionEngineTargetData(lp_build_engine);
+
+   util_cpu_detect();
+
+#if 0
+   /* For simulating less capable machines */
+   util_cpu_caps.has_sse3 = 0;
+   util_cpu_caps.has_ssse3 = 0;
+   util_cpu_caps.has_sse4_1 = 0;
+#endif
 }
 
 
diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c 
b/src/gallium/drivers/llvmpipe/lp_jit.c
index 8690941..466a2f5 100644
--- a/src/gallium/drivers/llvmpipe/lp_jit.c
+++ b/src/gallium/drivers/llvmpipe/lp_jit.c
@@ -171,15 +171,6 @@ lp_jit_screen_cleanup(struct llvmpipe_screen *screen)
 void
 lp_jit_screen_init(struct llvmpipe_screen *screen)
 {
-   util_cpu_detect();
-
-#if 0
-   /* For simulating less capable machines */
-   util_cpu_caps.has_sse3 = 0;
-   util_cpu_caps.has_ssse3 = 0;
-   util_cpu_caps.has_sse4_1 = 0;
-#endif
-
lp_build_init();
 
screen->module = lp_build_module;

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


Mesa (master): llvmpipe: Don't use fences when not using threads.

2010-04-24 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: bd6e9e33501ad4351029d0eb0efa6b83f9f05445
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bd6e9e33501ad4351029d0eb0efa6b83f9f05445

Author: José Fonseca 
Date:   Sat Apr 24 16:13:04 2010 +0100

llvmpipe: Don't use fences when not using threads.

lp_setup_flush has effect immediately.

---

 src/gallium/drivers/llvmpipe/lp_setup.c |   25 +++--
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c 
b/src/gallium/drivers/llvmpipe/lp_setup.c
index 0dad4c2..194f628 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -343,20 +343,25 @@ lp_setup_clear( struct lp_setup_context *setup,
 struct pipe_fence_handle *
 lp_setup_fence( struct lp_setup_context *setup )
 {
-   struct lp_scene *scene = lp_setup_get_current_scene(setup);
-   const unsigned rank = lp_scene_get_num_bins( scene ); /* xxx */
-   struct lp_fence *fence = lp_fence_create(rank);
+   if (setup->num_threads == 0) {
+  return NULL;
+   }
+   else {
+  struct lp_scene *scene = lp_setup_get_current_scene(setup);
+  const unsigned rank = lp_scene_get_num_bins( scene ); /* xxx */
+  struct lp_fence *fence = lp_fence_create(rank);
 
-   LP_DBG(DEBUG_SETUP, "%s rank %u\n", __FUNCTION__, rank);
+  LP_DBG(DEBUG_SETUP, "%s rank %u\n", __FUNCTION__, rank);
 
-   set_scene_state( setup, SETUP_ACTIVE );
+  set_scene_state( setup, SETUP_ACTIVE );
 
-   /* insert the fence into all command bins */
-   lp_scene_bin_everywhere( scene,
-   lp_rast_fence,
-   lp_rast_arg_fence(fence) );
+  /* insert the fence into all command bins */
+  lp_scene_bin_everywhere( scene,
+   lp_rast_fence,
+   lp_rast_arg_fence(fence) );
 
-   return (struct pipe_fence_handle *) fence;
+  return (struct pipe_fence_handle *) fence;
+   }
 }
 
 

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


Mesa (master): llvmpipe: Initialize dummy variable.

2010-04-24 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: aa7a47dcbdfff3c6858ff3618170ec17ca72d337
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=aa7a47dcbdfff3c6858ff3618170ec17ca72d337

Author: José Fonseca 
Date:   Sat Apr 24 16:13:18 2010 +0100

llvmpipe: Initialize dummy variable.

---

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

diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c 
b/src/gallium/drivers/llvmpipe/lp_setup.c
index 194f628..abc659c 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -243,7 +243,7 @@ lp_setup_flush( struct lp_setup_context *setup,
 
if (setup->scene) {
   struct lp_scene *scene = lp_setup_get_current_scene(setup);
-  union lp_rast_cmd_arg dummy;
+  union lp_rast_cmd_arg dummy = {0};
 
   if (flags & (PIPE_FLUSH_SWAPBUFFERS |
PIPE_FLUSH_FRAME)) {

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


Mesa (master): util: Fix unsigned <-> ptr conversions.

2010-04-24 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: ee15d5a0c40b252670ec9e261460bad82402443d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ee15d5a0c40b252670ec9e261460bad82402443d

Author: José Fonseca 
Date:   Sat Apr 24 16:13:41 2010 +0100

util: Fix unsigned <-> ptr conversions.

---

 src/gallium/auxiliary/util/u_surfaces.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_surfaces.c 
b/src/gallium/auxiliary/util/u_surfaces.c
index 0248120..668da8c 100644
--- a/src/gallium/auxiliary/util/u_surfaces.c
+++ b/src/gallium/auxiliary/util/u_surfaces.c
@@ -9,13 +9,13 @@
 static unsigned
 hash(void *key)
 {
-   return (unsigned)key;
+   return (unsigned)(uintptr_t)key;
 }
 
 static int
 compare(void *key1, void *key2)
 {
-   return (unsigned)key1 - (unsigned)key2;
+   return (unsigned)(uintptr_t)key1 - (unsigned)(uintptr_t)key2;
 }
 
 struct pipe_surface *
@@ -67,7 +67,7 @@ util_surfaces_do_detach(struct util_surfaces *us, struct 
pipe_surface *ps)
struct pipe_resource *pt = ps->texture;
if(pt->target == PIPE_TEXTURE_3D || pt->target == PIPE_TEXTURE_CUBE)
{   /* or 2D array */
-  void* key = (void*)(((ps->zslice + ps->face) << 8) | ps->level);
+  void* key = (void*)(uintptr_t)(((ps->zslice + ps->face) << 8) | 
ps->level);
   util_hash_table_remove(us->u.table, key);
}
else

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


Mesa (master): util: Add missing static keyword.

2010-04-24 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 1eeae05441f4cf3efa7079eec1fe4b70c5d9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1eeae05441f4cf3efa7079eec1fe4b70c5d9

Author: José Fonseca 
Date:   Sat Apr 24 16:13:54 2010 +0100

util: Add missing static keyword.

---

 src/gallium/auxiliary/util/u_format_s3tc.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_format_s3tc.c 
b/src/gallium/auxiliary/util/u_format_s3tc.c
index abc1951..66edb59 100644
--- a/src/gallium/auxiliary/util/u_format_s3tc.c
+++ b/src/gallium/auxiliary/util/u_format_s3tc.c
@@ -300,7 +300,7 @@ util_format_dxt5_rgba_unpack_rgba_8unorm(uint8_t *dst_row, 
unsigned dst_stride,
util_format_dxt5_rgba_fetch, 16);
 }
 
-void
+static INLINE void
 util_format_dxtn_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *src_row, unsigned 
src_stride,
unsigned width, unsigned height,

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


Mesa (master): mesa: Eliminate multiple va_list usage.

2010-04-24 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: cca8abe20ec9d1a560cc3fc97545922254d2a574
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cca8abe20ec9d1a560cc3fc97545922254d2a574

Author: José Fonseca 
Date:   Sat Apr 24 20:31:30 2010 +0100

mesa: Eliminate multiple va_list usage.

va_list is a mutable iterator. When passed to a function it will likely
point to somewhere else.

This fixes segmentation fault in glean vertProg1 on Ubuntu 9.10.

---

 src/mesa/shader/program_parse.tab.c |7 ---
 src/mesa/shader/program_parse.y |7 ---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/mesa/shader/program_parse.tab.c 
b/src/mesa/shader/program_parse.tab.c
index e5ef25e..99c4b2b 100644
--- a/src/mesa/shader/program_parse.tab.c
+++ b/src/mesa/shader/program_parse.tab.c
@@ -5557,7 +5557,6 @@ make_error_string(const char *fmt, ...)
char *str;
va_list args;
 
-   va_start(args, fmt);
 
/* Call vsnprintf once to determine how large the final string is.  Call it
 * again to do the actual formatting.  from the vsnprintf manual page:
@@ -5566,15 +5565,17 @@ make_error_string(const char *fmt, ...)
 *characters printed  (not including the trailing '\0' used to end
 *output to strings).
 */
+   va_start(args, fmt);
length = 1 + vsnprintf(NULL, 0, fmt, args);
+   va_end(args);
 
str = malloc(length);
if (str) {
+  va_start(args, fmt);
   vsnprintf(str, length, fmt, args);
+  va_end(args);
}
 
-   va_end(args);
-
return str;
 }
 
diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y
index 299e247..06c2db7 100644
--- a/src/mesa/shader/program_parse.y
+++ b/src/mesa/shader/program_parse.y
@@ -2596,7 +2596,6 @@ make_error_string(const char *fmt, ...)
char *str;
va_list args;
 
-   va_start(args, fmt);
 
/* Call vsnprintf once to determine how large the final string is.  Call it
 * again to do the actual formatting.  from the vsnprintf manual page:
@@ -2605,15 +2604,17 @@ make_error_string(const char *fmt, ...)
 *characters printed  (not including the trailing '\0' used to end
 *output to strings).
 */
+   va_start(args, fmt);
length = 1 + vsnprintf(NULL, 0, fmt, args);
+   va_end(args);
 
str = malloc(length);
if (str) {
+  va_start(args, fmt);
   vsnprintf(str, length, fmt, args);
+  va_end(args);
}
 
-   va_end(args);
-
return str;
 }
 

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


Mesa (master): llvmpipe: Implement shader bias.

2010-04-24 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: e54a86c6770491bb69168f3aef27e4c2dd1827d8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e54a86c6770491bb69168f3aef27e4c2dd1827d8

Author: José Fonseca 
Date:   Sat Apr 24 21:00:45 2010 +0100

llvmpipe: Implement shader bias.

Fixes glean glsl1 test: texture2D(), with bias.

---

 src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c |   21 +++--
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index c9b613e..415346c 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -842,6 +842,7 @@ lp_build_minify(struct lp_build_sample_context *bld,
  * \param s  vector of texcoord s values
  * \param t  vector of texcoord t values
  * \param r  vector of texcoord r values
+ * \param shader_lod_bias  vector float with the shader lod bias,
  * \param width  scalar int texture width
  * \param height  scalar int texture height
  * \param depth  scalar int texture depth
@@ -851,6 +852,7 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
   LLVMValueRef s,
   LLVMValueRef t,
   LLVMValueRef r,
+  LLVMValueRef shader_lod_bias,
   LLVMValueRef width,
   LLVMValueRef height,
   LLVMValueRef depth)
@@ -865,8 +867,8 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
else {
   const int dims = texture_dims(bld->static_state->target);
   struct lp_build_context *float_bld = &bld->float_bld;
-  LLVMValueRef lod_bias = LLVMConstReal(LLVMFloatType(),
-bld->static_state->lod_bias);
+  LLVMValueRef sampler_lod_bias = LLVMConstReal(LLVMFloatType(),
+
bld->static_state->lod_bias);
   LLVMValueRef min_lod = LLVMConstReal(LLVMFloatType(),
bld->static_state->min_lod);
   LLVMValueRef max_lod = LLVMConstReal(LLVMFloatType(),
@@ -940,8 +942,14 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
   /* compute lod = log2(rho) */
   lod = lp_build_log2(float_bld, rho);
 
-  /* add lod bias */
-  lod = LLVMBuildAdd(bld->builder, lod, lod_bias, "LOD bias");
+  /* add sampler lod bias */
+  lod = LLVMBuildAdd(bld->builder, lod, sampler_lod_bias, "sampler LOD 
bias");
+
+  /* add shader lod bias */
+  /* XXX for now we take only the first element since our lod is scalar */
+  shader_lod_bias = LLVMBuildExtractElement(bld->builder, shader_lod_bias,
+LLVMConstInt(LLVMInt32Type(), 
0, 0), "");
+  lod = LLVMBuildAdd(bld->builder, lod, shader_lod_bias, "shader LOD 
bias");
 
   /* clamp lod */
   lod = lp_build_clamp(float_bld, lod, min_lod, max_lod);
@@ -1527,6 +1535,7 @@ lp_build_sample_general(struct lp_build_sample_context 
*bld,
 LLVMValueRef s,
 LLVMValueRef t,
 LLVMValueRef r,
+LLVMValueRef lodbias,
 LLVMValueRef width,
 LLVMValueRef height,
 LLVMValueRef depth,
@@ -1564,7 +1573,7 @@ lp_build_sample_general(struct lp_build_sample_context 
*bld,
   /* Need to compute lod either to choose mipmap levels or to
* distinguish between minification/magnification with one mipmap level.
*/
-  lod = lp_build_lod_selector(bld, s, t, r, width, height, depth);
+  lod = lp_build_lod_selector(bld, s, t, r, lodbias, width, height, depth);
}
 
/*
@@ -2060,7 +2069,7 @@ lp_build_sample_soa(LLVMBuilderRef builder,
 row_stride_array, data_array, texel);
}
else {
-  lp_build_sample_general(&bld, unit, s, t, r,
+  lp_build_sample_general(&bld, unit, s, t, r, lodbias,
   width, height, depth,
   width_vec, height_vec, depth_vec,
   row_stride_array, img_stride_array,

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


Mesa (master): llvmpipe: Remove sp2lp.sh.

2010-04-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 8a70c47c4cf0c792f874e16517f2afd709e160a6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8a70c47c4cf0c792f874e16517f2afd709e160a6

Author: José Fonseca 
Date:   Sun Apr 25 12:12:54 2010 +0100

llvmpipe: Remove sp2lp.sh.

Irrelevant now that llvmpipe and softpipe grew so far apart.

---

 src/gallium/drivers/llvmpipe/sp2lp.sh |   34 -
 1 files changed, 0 insertions(+), 34 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/sp2lp.sh 
b/src/gallium/drivers/llvmpipe/sp2lp.sh
deleted file mode 100755
index c45a81c..000
--- a/src/gallium/drivers/llvmpipe/sp2lp.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-#
-# Port changes from softpipe to llvmpipe. Invoke as
-#
-#   sp2lp.sh 
-#
-# Note that this will only affect llvmpipe -- you still need to actually
-# cherry-pick/merge the softpipe changes themselves if they affect directories
-# outside src/gallium/drivers/softpipe
-
-git format-patch \
-   --keep-subject \
-   --relative=src/gallium/drivers/softpipe \
-   --src-prefix=a/src/gallium/drivers/llvmpipe/ \
-   --dst-prefix=b/src/gallium/drivers/llvmpipe/ \
-   --stdout "$1^1..$1" \
-| sed \
-   -e 's/\/llvmpipe/g' \
-   -e 's/\/lp/g' \
-   -e 's/\/lpt/g' \
-   -e 's/\/lps/g' \
-   -e 's/\/lpfs/g' \
-   -e 's/\/lptex/g' \
-   -e 's/\/llvmpipe_\0/g' \
-   -e 's/\/llvmpipe_cached_tex_tile/g' \
-   -e 's/_get_cached_tile_tex\>/_get_cached_tex_tile/g' \
-   -e 's/\/TEX_TILE_SIZE/g' \
-   -e 's/\/tex_tile_address/g' \
-   -e 's/\data\.color\>/tile->color/g' \
-| patch -p1

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


Mesa (master): llvmpipe: lp_tex_sample_llvm.c -> lp_tex_sample.c

2010-04-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 7cebd16fbbb68d76b516098f5e6d6a1fc415b8b0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7cebd16fbbb68d76b516098f5e6d6a1fc415b8b0

Author: José Fonseca 
Date:   Sun Apr 25 12:11:36 2010 +0100

llvmpipe: lp_tex_sample_llvm.c -> lp_tex_sample.c

'llvm' suffix unnecessary now that the C sampling version disappeared.

---

 src/gallium/drivers/llvmpipe/Makefile  |2 +-
 src/gallium/drivers/llvmpipe/SConscript|2 +-
 .../{lp_tex_sample_llvm.c => lp_tex_sample.c}  |0 
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/Makefile 
b/src/gallium/drivers/llvmpipe/Makefile
index 7bf5b09..4ea3675 100644
--- a/src/gallium/drivers/llvmpipe/Makefile
+++ b/src/gallium/drivers/llvmpipe/Makefile
@@ -40,7 +40,7 @@ C_SOURCES = \
lp_state_vertex.c \
lp_state_vs.c \
lp_surface.c \
-   lp_tex_sample_llvm.c \
+   lp_tex_sample.c \
lp_texture.c \
lp_tile_image.c \
lp_tile_soa.c
diff --git a/src/gallium/drivers/llvmpipe/SConscript 
b/src/gallium/drivers/llvmpipe/SConscript
index b9e9826..2911cf2 100644
--- a/src/gallium/drivers/llvmpipe/SConscript
+++ b/src/gallium/drivers/llvmpipe/SConscript
@@ -60,7 +60,7 @@ llvmpipe = env.ConvenienceLibrary(
'lp_state_vertex.c',
'lp_state_vs.c',
'lp_surface.c',
-   'lp_tex_sample_llvm.c',
+   'lp_tex_sample.c',
'lp_texture.c',
'lp_tile_image.c',
'lp_tile_soa.c',
diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c 
b/src/gallium/drivers/llvmpipe/lp_tex_sample.c
similarity index 100%
rename from src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c
rename to src/gallium/drivers/llvmpipe/lp_tex_sample.c

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


Mesa (master): softpipe: More accurate softpipe_is_format_supported().

2010-04-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 7e4ce65d714624d5d2888c59f0d83ffda0662834
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7e4ce65d714624d5d2888c59f0d83ffda0662834

Author: José Fonseca 
Date:   Sun Apr 25 14:51:33 2010 +0100

softpipe: More accurate softpipe_is_format_supported().

Unfortunately there are some heavy limitations on supported render target
formats due to the way clear values are used internally.

---

 src/gallium/drivers/softpipe/sp_screen.c |   74 ++
 1 files changed, 55 insertions(+), 19 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_screen.c 
b/src/gallium/drivers/softpipe/sp_screen.c
index 8406aa1..11aa0c4 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -27,6 +27,7 @@
 
 
 #include "util/u_memory.h"
+#include "util/u_format.h"
 #include "util/u_format_s3tc.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
@@ -144,42 +145,77 @@ static boolean
 softpipe_is_format_supported( struct pipe_screen *screen,
   enum pipe_format format, 
   enum pipe_texture_target target,
-  unsigned tex_usage, 
+  unsigned bind,
   unsigned geom_flags )
 {
struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
+   const struct util_format_description *format_desc;
 
assert(target == PIPE_TEXTURE_1D ||
   target == PIPE_TEXTURE_2D ||
   target == PIPE_TEXTURE_3D ||
   target == PIPE_TEXTURE_CUBE);
 
-   switch(format) {
-   case PIPE_FORMAT_DXT1_RGB:
-   case PIPE_FORMAT_DXT1_RGBA:
-   case PIPE_FORMAT_DXT3_RGBA:
-   case PIPE_FORMAT_DXT5_RGBA:
-  if (tex_usage & PIPE_BIND_RENDER_TARGET)
+   format_desc = util_format_description(format);
+   if (!format_desc)
+  return FALSE;
+
+   if (bind & (PIPE_BIND_DISPLAY_TARGET |
+   PIPE_BIND_SCANOUT |
+   PIPE_BIND_SHARED)) {
+  if(!winsys->is_displaytarget_format_supported(winsys, bind, format))
  return FALSE;
-  else
- return util_format_s3tc_enabled;
+   }
 
-   case PIPE_FORMAT_Z32_FLOAT:
-   case PIPE_FORMAT_NONE:
-  return FALSE;
+   if (bind & PIPE_BIND_RENDER_TARGET) {
+  if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS)
+ return FALSE;
 
-   default:
-  break;
+  /*
+   * Although possible, it is unnatural to render into compressed or YUV
+   * surfaces. So disable these here to avoid going into weird paths
+   * inside the state trackers.
+   */
+  if (format_desc->block.width != 1 ||
+  format_desc->block.height != 1)
+ return FALSE;
+
+  /*
+   * TODO: Unfortunately we cannot render into anything more than 32 bits
+   * because we encode color clear values into a 32bit word.
+   */
+  if (format_desc->block.bits > 32)
+ return FALSE;
}
 
-   if(tex_usage & (PIPE_BIND_DISPLAY_TARGET |
-   PIPE_BIND_SCANOUT |
-   PIPE_BIND_SHARED)) {
-  if(!winsys->is_displaytarget_format_supported(winsys, tex_usage, format))
+   if (bind & PIPE_BIND_DEPTH_STENCIL) {
+  if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
  return FALSE;
+
+  /*
+   * TODO: Unfortunately we cannot render into anything more than 32 bits
+   * because we encode depth and stencil clear values into a 32bit word.
+   */
+  if (format_desc->block.bits > 32)
+ return FALSE;
+
+  /*
+   * TODO: eliminate this restriction
+   */
+  if (format == PIPE_FORMAT_Z32_FLOAT)
+ return FALSE;
+   }
+
+   /*
+* All other operations (sampling, transfer, etc).
+*/
+
+   if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
+  return util_format_s3tc_enabled;
}
 
-   /* XXX: this is often a lie.  Pull in logic from llvmpipe to fix.
+   /*
+* Everything else should be supported by u_format.
 */
return TRUE;
 }

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


Mesa (master): llvmpipe: Cleanup llvmpipe_is_format_supported().

2010-04-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: adc7cd6240cb7bc79743871db6ce5b95325b8807
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=adc7cd6240cb7bc79743871db6ce5b95325b8807

Author: José Fonseca 
Date:   Sun Apr 25 14:52:27 2010 +0100

llvmpipe: Cleanup llvmpipe_is_format_supported().

It should be just cosmetic.

---

 src/gallium/drivers/llvmpipe/lp_screen.c |   39 ++---
 1 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index 88c0604..00a897c 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -168,7 +168,7 @@ static boolean
 llvmpipe_is_format_supported( struct pipe_screen *_screen,
   enum pipe_format format, 
   enum pipe_texture_target target,
-  unsigned tex_usage, 
+  unsigned bind,
   unsigned geom_flags )
 {
struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
@@ -176,7 +176,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
const struct util_format_description *format_desc;
 
format_desc = util_format_description(format);
-   if(!format_desc)
+   if (!format_desc)
   return FALSE;
 
assert(target == PIPE_TEXTURE_1D ||
@@ -184,43 +184,42 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
   target == PIPE_TEXTURE_3D ||
   target == PIPE_TEXTURE_CUBE);
 
-   if(tex_usage & PIPE_BIND_RENDER_TARGET) {
-  if(format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN)
+   if (bind & PIPE_BIND_RENDER_TARGET) {
+  if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS)
  return FALSE;
 
-  if(format_desc->block.width != 1 ||
- format_desc->block.height != 1)
+  if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN)
  return FALSE;
 
-  if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB &&
- format_desc->colorspace != UTIL_FORMAT_COLORSPACE_SRGB)
+  if (format_desc->block.width != 1 ||
+  format_desc->block.height != 1)
  return FALSE;
}
 
-   if(tex_usage & PIPE_BIND_DISPLAY_TARGET) {
-  if(!winsys->is_displaytarget_format_supported(winsys, tex_usage, format))
+   if (bind & PIPE_BIND_DISPLAY_TARGET) {
+  if(!winsys->is_displaytarget_format_supported(winsys, bind, format))
  return FALSE;
}
 
-   if(tex_usage & PIPE_BIND_DEPTH_STENCIL) {
-  if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
+   if (bind & PIPE_BIND_DEPTH_STENCIL) {
+  if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN)
+ return FALSE;
+
+  if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
  return FALSE;
 
   /* FIXME: Temporary restriction. See lp_state_fs.c. */
-  if(format_desc->block.bits != 32)
+  if (format_desc->block.bits != 32)
  return FALSE;
}
 
-   switch(format) {
-   case PIPE_FORMAT_DXT1_RGB:
-   case PIPE_FORMAT_DXT1_RGBA:
-   case PIPE_FORMAT_DXT3_RGBA:
-   case PIPE_FORMAT_DXT5_RGBA:
+   if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
   return util_format_s3tc_enabled;
-   default:
-  break;
}
 
+   /*
+* Everything else should be supported by u_format.
+*/
return TRUE;
 }
 

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


Mesa (master): llvmpipe: Replace tile_read/ write with more descriptive swizzle/unswizzle verbs.

2010-04-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 23df86d851dd6cbce1ddd7a45424c7bf14c04a3e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=23df86d851dd6cbce1ddd7a45424c7bf14c04a3e

Author: José Fonseca 
Date:   Sun Apr 25 14:53:40 2010 +0100

llvmpipe: Replace tile_read/write with more descriptive swizzle/unswizzle verbs.

---

 src/gallium/drivers/llvmpipe/lp_rast.c   |6 ++-
 src/gallium/drivers/llvmpipe/lp_tile_image.c |4 +-
 src/gallium/drivers/llvmpipe/lp_tile_soa.h   |9 --
 src/gallium/drivers/llvmpipe/lp_tile_soa.py  |   41 +++---
 4 files changed, 36 insertions(+), 24 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c 
b/src/gallium/drivers/llvmpipe/lp_rast.c
index 0aae254..400404f 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -121,9 +121,11 @@ lp_rast_end( struct lp_rasterizer *rast )
 
rast->curr_scene = NULL;
 
+#ifdef DEBUG
if (0)
-  debug_printf("Post render scene: tile read: %d  tile write: %d\n",
-   tile_read_count, tile_write_count);
+  debug_printf("Post render scene: tile unswizzle: %u tile swizzle: %u\n",
+   lp_tile_unswizzle_count, lp_tile_swizzle_count);
+#endif
 }
 
 
diff --git a/src/gallium/drivers/llvmpipe/lp_tile_image.c 
b/src/gallium/drivers/llvmpipe/lp_tile_image.c
index 7a2cc3e..2b63992 100644
--- a/src/gallium/drivers/llvmpipe/lp_tile_image.c
+++ b/src/gallium/drivers/llvmpipe/lp_tile_image.c
@@ -201,7 +201,7 @@ lp_tiled_to_linear(const void *src, void *dst,
 uint byte_offset = tile_offset * bytes_per_tile;
 const uint8_t *src_tile = (uint8_t *) src + byte_offset;
 
-lp_tile_write_4ub(format,
+lp_tile_unswizzle_4ub(format,
   src_tile,
   dst, dst_stride,
   ii, jj, tile_w, tile_h);
@@ -290,7 +290,7 @@ lp_linear_to_tiled(const void *src, void *dst,
 uint byte_offset = tile_offset * bytes_per_tile;
 uint8_t *dst_tile = (uint8_t *) dst + byte_offset;
 
-lp_tile_read_4ub(format,
+lp_tile_swizzle_4ub(format,
  dst_tile,
  src, src_stride,
  ii, jj, tile_w, tile_h);
diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.h 
b/src/gallium/drivers/llvmpipe/lp_tile_soa.h
index 634d8df..07f71b8 100644
--- a/src/gallium/drivers/llvmpipe/lp_tile_soa.h
+++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.h
@@ -51,7 +51,10 @@ tile_offset[TILE_VECTOR_HEIGHT][TILE_VECTOR_WIDTH];
 #define TILE_Y_STRIDE (TILE_VECTOR_HEIGHT * TILE_SIZE * NUM_CHANNELS) //1024
 
 
-extern int tile_write_count, tile_read_count;
+#ifdef DEBUG
+extern unsigned lp_tile_unswizzle_count;
+extern unsigned lp_tile_swizzle_count;
+#endif
 
 
 /**
@@ -73,14 +76,14 @@ tile_pixel_offset(unsigned x, unsigned y, unsigned c)
 
 
 void
-lp_tile_read_4ub(enum pipe_format format,
+lp_tile_swizzle_4ub(enum pipe_format format,
  uint8_t *dst,
  const void *src, unsigned src_stride,
  unsigned x, unsigned y, unsigned w, unsigned h);
 
 
 void
-lp_tile_write_4ub(enum pipe_format format,
+lp_tile_unswizzle_4ub(enum pipe_format format,
   const uint8_t *src,
   void *dst, unsigned dst_stride,
   unsigned x, unsigned y, unsigned w, unsigned h);
diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py 
b/src/gallium/drivers/llvmpipe/lp_tile_soa.py
index 4e9cd7e..b2f800a 100644
--- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py
+++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py
@@ -75,7 +75,7 @@ def generate_format_read(format, dst_channel, 
dst_native_type, dst_suffix):
 src_native_type = native_type(format)
 
 print 'static void'
-print 'lp_tile_%s_read_%s(%s *dst, const uint8_t *src, unsigned 
src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, 
dst_suffix, dst_native_type)
+print 'lp_tile_%s_swizzle_%s(%s *dst, const uint8_t *src, unsigned 
src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, 
dst_suffix, dst_native_type)
 print '{'
 print '   unsigned x, y;'
 print '   const uint8_t *src_row = src + y0*src_stride;'
@@ -193,7 +193,7 @@ def pack_rgba(format, src_channel, r, g, b, a):
 return expr
 
 
-def emit_unrolled_write_code(format, src_channel):
+def emit_unrolled_unswizzle_code(format, src_channel):
 '''Emit code for writing a block based on unrolled loops.
 This is considerably faster than the TILE_PIXEL-based code below.
 '''
@@ -223,7 +223,7 @@ def emit_unrolled_write_code(format, src_channel):
 print '   }'
 
 
-def emit_tile_pixel_write_code(format, src_channel):
+def emit_tile_pixel_unswizzle_code(format, src_channel):
 '''Emit code for writing a block based on the TILE_PIXEL macro.'''
 dst_native_type = native_type(format)
 
@@ -273,7

Mesa (master): softpipe: Hardcode TILE_CLEAR_OPTIMIZATION to 1.

2010-04-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 89f244931f444056a1ccf544e608b533fa993fa2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=89f244931f444056a1ccf544e608b533fa993fa2

Author: José Fonseca 
Date:   Sun Apr 25 15:05:41 2010 +0100

softpipe: Hardcode TILE_CLEAR_OPTIMIZATION to 1.

The un-optimized path relies on surface_fill which can only handle formats
with depth <= 32, so it is pointless to keep it around.

---

 src/gallium/drivers/softpipe/sp_clear.c  |   10 --
 src/gallium/drivers/softpipe/sp_tile_cache.c |9 +
 src/gallium/drivers/softpipe/sp_tile_cache.h |2 --
 3 files changed, 1 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_clear.c 
b/src/gallium/drivers/softpipe/sp_clear.c
index 5f13045..ae3f00f 100644
--- a/src/gallium/drivers/softpipe/sp_clear.c
+++ b/src/gallium/drivers/softpipe/sp_clear.c
@@ -69,11 +69,6 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, 
const float *rgba,
 
  util_pack_color(rgba, ps->format, &uc);
  sp_tile_cache_clear(softpipe->cbuf_cache[i], rgba, uc.ui);
-
-#if !TILE_CLEAR_OPTIMIZATION
- /* non-cached surface */
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, uc.ui);
-#endif
   }
}
 
@@ -83,11 +78,6 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, 
const float *rgba,
 
   cv = util_pack_z_stencil(ps->format, depth, stencil);
   sp_tile_cache_clear(softpipe->zsbuf_cache, zero, cv);
-
-#if !TILE_CLEAR_OPTIMIZATION
-  /* non-cached surface */
-  pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, cv);
-#endif
}
 
softpipe->dirty_render_cache = TRUE;
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c 
b/src/gallium/drivers/softpipe/sp_tile_cache.c
index d996c2a..4e5a13b 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -103,7 +103,7 @@ sp_create_tile_cache( struct pipe_context *pipe )
* However, it breaks clearing in other situations (such as in
* progs/tests/drawbuffers, see bug 24402).
*/
-#if 0 && TILE_CLEAR_OPTIMIZATION
+#if 0
   /* set flags to indicate all the tiles are cleared */
   memset(tc->clear_flags, 255, sizeof(tc->clear_flags));
 #endif
@@ -344,9 +344,7 @@ sp_flush_tile_cache(struct softpipe_tile_cache *tc)
  }
   }
 
-#if TILE_CLEAR_OPTIMIZATION
   sp_tile_cache_flush_clear(tc);
-#endif
}
 
 #if 0
@@ -448,13 +446,8 @@ sp_tile_cache_clear(struct softpipe_tile_cache *tc, const 
float *rgba,
 
tc->clear_val = clearValue;
 
-#if TILE_CLEAR_OPTIMIZATION
/* set flags to indicate all the tiles are cleared */
memset(tc->clear_flags, 255, sizeof(tc->clear_flags));
-#else
-   /* disable the optimization */
-   memset(tc->clear_flags, 0, sizeof(tc->clear_flags));
-#endif
 
for (pos = 0; pos < NUM_ENTRIES; pos++) {
   struct softpipe_cached_tile *tile = tc->entries + pos;
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.h 
b/src/gallium/drivers/softpipe/sp_tile_cache.h
index 753d8c0..e03d53e 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.h
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.h
@@ -28,8 +28,6 @@
 #ifndef SP_TILE_CACHE_H
 #define SP_TILE_CACHE_H
 
-#define TILE_CLEAR_OPTIMIZATION 1
-
 
 #include "pipe/p_compiler.h"
 

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


Mesa (master): llvmpipe: Fix buffer overflow unswizzling several formats.

2010-04-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 5745bcb2dbfcaab53df89125d08689b51b9126ea
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5745bcb2dbfcaab53df89125d08689b51b9126ea

Author: José Fonseca 
Date:   Sun Apr 25 15:40:06 2010 +0100

llvmpipe: Fix buffer overflow unswizzling several formats.

Array formats without for channels were being advanced as four channels,
causing buffer overflows.

---

 src/gallium/drivers/llvmpipe/lp_tile_soa.py |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py 
b/src/gallium/drivers/llvmpipe/lp_tile_soa.py
index b2f800a..5ab63cb 100644
--- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py
+++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py
@@ -257,7 +257,7 @@ def emit_tile_pixel_unswizzle_code(format, src_channel):
 value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i]
 value = conversion_expr(src_channel, dst_channel, 
dst_native_type, value, clamp=False)
 print ' *dst_pixel++ = %s;' % value
-else:
+elif dst_channel.size:
 print ' ++dst_pixel;'
 else:
 assert False

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


Mesa (master): llvmpipe: llvmpipe_flush_texture -> llvmpipe_flush_resource

2010-04-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 7951630d0877fc3c293151ad6476bec7288e63c6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7951630d0877fc3c293151ad6476bec7288e63c6

Author: José Fonseca 
Date:   Sun Apr 25 15:49:03 2010 +0100

llvmpipe: llvmpipe_flush_texture -> llvmpipe_flush_resource

---

 src/gallium/drivers/llvmpipe/lp_flush.c   |   19 ---
 src/gallium/drivers/llvmpipe/lp_flush.h   |2 +-
 src/gallium/drivers/llvmpipe/lp_surface.c |4 ++--
 src/gallium/drivers/llvmpipe/lp_texture.c |2 +-
 4 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c 
b/src/gallium/drivers/llvmpipe/lp_flush.c
index 3627dbd..1534913 100644
--- a/src/gallium/drivers/llvmpipe/lp_flush.c
+++ b/src/gallium/drivers/llvmpipe/lp_flush.c
@@ -97,19 +97,16 @@ llvmpipe_flush( struct pipe_context *pipe,
  * Flush context if necessary.
  *
  * TODO: move this logic to an auxiliary library?
- *
- * FIXME: We must implement DISCARD/DONTBLOCK/UNSYNCHRONIZED/etc for
- * textures to avoid blocking.
  */
 boolean
-llvmpipe_flush_texture(struct pipe_context *pipe,
-   struct pipe_resource *texture,
-   unsigned face,
-   unsigned level,
-   unsigned flush_flags,
-   boolean read_only,
-   boolean cpu_access,
-   boolean do_not_flush)
+llvmpipe_flush_resource(struct pipe_context *pipe,
+struct pipe_resource *texture,
+unsigned face,
+unsigned level,
+unsigned flush_flags,
+boolean read_only,
+boolean cpu_access,
+boolean do_not_flush)
 {
unsigned referenced;
 
diff --git a/src/gallium/drivers/llvmpipe/lp_flush.h 
b/src/gallium/drivers/llvmpipe/lp_flush.h
index 2375d22..e516cee 100644
--- a/src/gallium/drivers/llvmpipe/lp_flush.h
+++ b/src/gallium/drivers/llvmpipe/lp_flush.h
@@ -37,7 +37,7 @@ void llvmpipe_flush(struct pipe_context *pipe, unsigned flags,
 struct pipe_fence_handle **fence);
 
 boolean
-llvmpipe_flush_texture(struct pipe_context *pipe,
+llvmpipe_flush_resource(struct pipe_context *pipe,
struct pipe_resource *texture,
unsigned face,
unsigned level,
diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c 
b/src/gallium/drivers/llvmpipe/lp_surface.c
index ca03440..4934055 100644
--- a/src/gallium/drivers/llvmpipe/lp_surface.c
+++ b/src/gallium/drivers/llvmpipe/lp_surface.c
@@ -59,14 +59,14 @@ lp_surface_copy(struct pipe_context *pipe,
struct llvmpipe_resource *dst_tex = llvmpipe_resource(dst->texture);
const enum pipe_format format = src_tex->base.format;
 
-   llvmpipe_flush_texture(pipe,
+   llvmpipe_flush_resource(pipe,
   dst->texture, dst->face, dst->level,
   0, /* flush_flags */
   FALSE, /* read_only */
   FALSE, /* cpu_access */
   FALSE); /* do_not_flush */
 
-   llvmpipe_flush_texture(pipe,
+   llvmpipe_flush_resource(pipe,
   src->texture, src->face, src->level,
   0, /* flush_flags */
   TRUE, /* read_only */
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c 
b/src/gallium/drivers/llvmpipe/lp_texture.c
index 0c66f4a..e1aed7f 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -566,7 +566,7 @@ llvmpipe_transfer_map( struct pipe_context *pipe,
 * Transfers, like other pipe operations, must happen in order, so flush the
 * context if necessary.
 */
-   llvmpipe_flush_texture(pipe,
+   llvmpipe_flush_resource(pipe,
   transfer->resource,
  transfer->sr.face,
  transfer->sr.level,

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


Mesa (master): llvmpipe: Cleanup/improve llvmpipe_flush_resource usage.

2010-04-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 43b85af56efbe6eb06f4e62d23e9f6f583c5ec2e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=43b85af56efbe6eb06f4e62d23e9f6f583c5ec2e

Author: José Fonseca 
Date:   Sun Apr 25 16:59:09 2010 +0100

llvmpipe: Cleanup/improve llvmpipe_flush_resource usage.

Recognize PIPE_TRANSFER_UNSYNCHRONIZED and PIPE_TRANSFER_DONTBLOCK.

---

 src/gallium/drivers/llvmpipe/lp_flush.c   |   11 ++---
 src/gallium/drivers/llvmpipe/lp_flush.h   |   19 ---
 src/gallium/drivers/llvmpipe/lp_surface.c |   20 
 src/gallium/drivers/llvmpipe/lp_texture.c |   34 +---
 4 files changed, 48 insertions(+), 36 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c 
b/src/gallium/drivers/llvmpipe/lp_flush.c
index 1534913..470132d 100644
--- a/src/gallium/drivers/llvmpipe/lp_flush.c
+++ b/src/gallium/drivers/llvmpipe/lp_flush.c
@@ -96,6 +96,9 @@ llvmpipe_flush( struct pipe_context *pipe,
 /**
  * Flush context if necessary.
  *
+ * Returns FALSE if it would have block, but do_not_block was set, TRUE
+ * otherwise.
+ *
  * TODO: move this logic to an auxiliary library?
  */
 boolean
@@ -106,7 +109,7 @@ llvmpipe_flush_resource(struct pipe_context *pipe,
 unsigned flush_flags,
 boolean read_only,
 boolean cpu_access,
-boolean do_not_flush)
+boolean do_not_block)
 {
unsigned referenced;
 
@@ -115,9 +118,6 @@ llvmpipe_flush_resource(struct pipe_context *pipe,
if ((referenced & PIPE_REFERENCED_FOR_WRITE) ||
((referenced & PIPE_REFERENCED_FOR_READ) && !read_only)) {
 
-  if (do_not_flush)
- return FALSE;
-
   /*
* TODO: The semantics of these flush flags are too obtuse. They should
* disappear and the pipe driver should just ensure that all visible
@@ -136,6 +136,9 @@ llvmpipe_flush_resource(struct pipe_context *pipe,
 
  struct pipe_fence_handle *fence = NULL;
 
+ if (do_not_block)
+return FALSE;
+
  pipe->flush(pipe, flush_flags, &fence);
 
  if (fence) {
diff --git a/src/gallium/drivers/llvmpipe/lp_flush.h 
b/src/gallium/drivers/llvmpipe/lp_flush.h
index e516cee..1b38820 100644
--- a/src/gallium/drivers/llvmpipe/lp_flush.h
+++ b/src/gallium/drivers/llvmpipe/lp_flush.h
@@ -33,17 +33,18 @@
 struct pipe_context;
 struct pipe_fence_handle;
 
-void llvmpipe_flush(struct pipe_context *pipe, unsigned flags,
-struct pipe_fence_handle **fence);
+void
+llvmpipe_flush(struct pipe_context *pipe, unsigned flags,
+   struct pipe_fence_handle **fence);
 
 boolean
 llvmpipe_flush_resource(struct pipe_context *pipe,
-   struct pipe_resource *texture,
-   unsigned face,
-   unsigned level,
-   unsigned flush_flags,
-   boolean read_only,
-   boolean cpu_access,
-   boolean do_not_flush);
+struct pipe_resource *texture,
+unsigned face,
+unsigned level,
+unsigned flush_flags,
+boolean read_only,
+boolean cpu_access,
+boolean do_not_block);
 
 #endif
diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c 
b/src/gallium/drivers/llvmpipe/lp_surface.c
index 4934055..1432782 100644
--- a/src/gallium/drivers/llvmpipe/lp_surface.c
+++ b/src/gallium/drivers/llvmpipe/lp_surface.c
@@ -60,18 +60,18 @@ lp_surface_copy(struct pipe_context *pipe,
const enum pipe_format format = src_tex->base.format;
 
llvmpipe_flush_resource(pipe,
-  dst->texture, dst->face, dst->level,
-  0, /* flush_flags */
-  FALSE, /* read_only */
-  FALSE, /* cpu_access */
-  FALSE); /* do_not_flush */
+   dst->texture, dst->face, dst->level,
+   0, /* flush_flags */
+   FALSE, /* read_only */
+   FALSE, /* cpu_access */
+   FALSE); /* do_not_block */
 
llvmpipe_flush_resource(pipe,
-  src->texture, src->face, src->level,
-  0, /* flush_flags */
-  TRUE, /* read_only */
-  FALSE, /* cpu_access */
-  FALSE); /* do_not_flush */
+   src->texture, src->face, src->level,
+   0, /* flush_flags */
+   TRUE, /* read_only */
+   FALSE, /* cpu_access */
+   FALSE); /* do_not_block */
 
/*
printf("surface copy from %u to %u: %u,%u to %u,%u %u x %u\n",
diff --git a/src/gallium/d

Mesa (master): softpipe: Make softpipe transfers in-order.

2010-04-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 53e94bd4adb218c5974c522389c3bcf40f3fa7e8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=53e94bd4adb218c5974c522389c3bcf40f3fa7e8

Author: José Fonseca 
Date:   Sun Apr 25 17:03:48 2010 +0100

softpipe: Make softpipe transfers in-order.

Transfer, being now a context operation, should happen in order with
all other contexts operations. If there is rendering pending on the
resource then the driver must flush and potentially wait itself
internally.

Instead of avoiding using transfers internally (as done in llvmpipe) I've
opted to simply pass PIPE_TRANSFER_UNSYNCHRONIZED in all internal
transfers, to avoid infinite recursion.

---

 src/gallium/drivers/softpipe/sp_flush.c  |   68 ++
 src/gallium/drivers/softpipe/sp_flush.h  |   17 +-
 src/gallium/drivers/softpipe/sp_tex_tile_cache.c |3 +-
 src/gallium/drivers/softpipe/sp_texture.c|   22 +++
 src/gallium/drivers/softpipe/sp_tile_cache.c |3 +-
 5 files changed, 109 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_flush.c 
b/src/gallium/drivers/softpipe/sp_flush.c
index 508fe8f..5024fc8 100644
--- a/src/gallium/drivers/softpipe/sp_flush.c
+++ b/src/gallium/drivers/softpipe/sp_flush.c
@@ -104,3 +104,71 @@ softpipe_flush( struct pipe_context *pipe,
   *fence = NULL;
 }
 
+
+/**
+ * Flush context if necessary.
+ *
+ * Returns FALSE if it would have block, but do_not_block was set, TRUE
+ * otherwise.
+ *
+ * TODO: move this logic to an auxiliary library?
+ */
+boolean
+softpipe_flush_resource(struct pipe_context *pipe,
+struct pipe_resource *texture,
+unsigned face,
+unsigned level,
+unsigned flush_flags,
+boolean read_only,
+boolean cpu_access,
+boolean do_not_block)
+{
+   unsigned referenced;
+
+   referenced = pipe->is_resource_referenced(pipe, texture, face, level);
+
+   if ((referenced & PIPE_REFERENCED_FOR_WRITE) ||
+   ((referenced & PIPE_REFERENCED_FOR_READ) && !read_only)) {
+
+  /*
+   * TODO: The semantics of these flush flags are too obtuse. They should
+   * disappear and the pipe driver should just ensure that all visible
+   * side-effects happen when they need to happen.
+   */
+  if (referenced & PIPE_REFERENCED_FOR_WRITE)
+ flush_flags |= PIPE_FLUSH_RENDER_CACHE;
+
+  if (referenced & PIPE_REFERENCED_FOR_READ)
+ flush_flags |= PIPE_FLUSH_TEXTURE_CACHE;
+
+  if (cpu_access) {
+ /*
+  * Flush and wait.
+  */
+
+ struct pipe_fence_handle *fence = NULL;
+
+ if (do_not_block)
+return FALSE;
+
+ pipe->flush(pipe, flush_flags, &fence);
+
+ if (fence) {
+/*
+ * This is for illustrative purposes only, as softpipe does not
+ * have fences.
+ */
+pipe->screen->fence_finish(pipe->screen, fence, 0);
+pipe->screen->fence_reference(pipe->screen, &fence, NULL);
+ }
+  } else {
+ /*
+  * Just flush.
+  */
+
+ pipe->flush(pipe, flush_flags, NULL);
+  }
+   }
+
+   return TRUE;
+}
diff --git a/src/gallium/drivers/softpipe/sp_flush.h 
b/src/gallium/drivers/softpipe/sp_flush.h
index 68d9b5f..cb97482 100644
--- a/src/gallium/drivers/softpipe/sp_flush.h
+++ b/src/gallium/drivers/softpipe/sp_flush.h
@@ -28,10 +28,23 @@
 #ifndef SP_FLUSH_H
 #define SP_FLUSH_H
 
+#include "pipe/p_compiler.h"
+
 struct pipe_context;
 struct pipe_fence_handle;
 
-void softpipe_flush(struct pipe_context *pipe, unsigned flags,
-struct pipe_fence_handle **fence);
+void
+softpipe_flush(struct pipe_context *pipe, unsigned flags,
+   struct pipe_fence_handle **fence);
+
+boolean
+softpipe_flush_resource(struct pipe_context *pipe,
+struct pipe_resource *texture,
+unsigned face,
+unsigned level,
+unsigned flush_flags,
+boolean read_only,
+boolean cpu_access,
+boolean do_not_block);
 
 #endif
diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c 
b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
index c79f5fb..fbce9e0 100644
--- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
@@ -248,7 +248,8 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
  addr.bits.face, 
  addr.bits.level, 
  addr.bits.z, 
- PIPE_TRANSFER_READ, 0, 0,
+ PIPE_TRANSFER_READ | PIPE_TRANSFER_UNSYNCHRONIZED,
+ 0, 0,
  u_minif

Mesa (master): draw: Respect pipe_vertex_buffer:: max_index in llvm generated code.

2010-04-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 4dd1a568404dcf068cb111db04bb6e904b91d7bd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4dd1a568404dcf068cb111db04bb6e904b91d7bd

Author: José Fonseca 
Date:   Sun Apr 25 21:43:49 2010 +0100

draw: Respect pipe_vertex_buffer::max_index in llvm generated code.

Everybody should respect max_index, specially llvm generated code, which
likes to eat vertices 4 at a time, so it may end up chew a bit a bit more
than actually exists.

---

 src/gallium/auxiliary/draw/draw_llvm.c |   12 +---
 src/gallium/auxiliary/draw/draw_llvm.h |5 -
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 936753f..703b46b 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -286,10 +286,16 @@ generate_fetch(LLVMBuilderRef builder,
LLVMValueRef vbuffer_ptr = LLVMBuildGEP(builder, vbuffers_ptr,
&indices, 1, "");
LLVMValueRef vb_stride = draw_jit_vbuffer_stride(builder, vbuf);
+   LLVMValueRef vb_max_index = draw_jit_vbuffer_max_index(builder, vbuf);
LLVMValueRef vb_buffer_offset = draw_jit_vbuffer_offset(builder, vbuf);
-   LLVMValueRef stride = LLVMBuildMul(builder,
-  vb_stride,
-  index, "");
+   LLVMValueRef cond;
+   LLVMValueRef stride;
+
+   cond = LLVMBuildICmp(builder, LLVMIntULE, index, vb_max_index, "");
+
+   index = LLVMBuildSelect(builder, cond, index, vb_max_index, "");
+
+   stride = LLVMBuildMul(builder, vb_stride, index, "");
 
vbuffer_ptr = LLVMBuildLoad(builder, vbuffer_ptr, "vbuffer");
 
diff --git a/src/gallium/auxiliary/draw/draw_llvm.h 
b/src/gallium/auxiliary/draw/draw_llvm.h
index 28b9044..20f4f3d 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.h
+++ b/src/gallium/auxiliary/draw/draw_llvm.h
@@ -78,7 +78,10 @@ struct draw_jit_context
 #define draw_jit_vbuffer_stride(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, 0, "stride")
 
-#define draw_jit_vbuffer_offset(_builder, _ptr) \
+#define draw_jit_vbuffer_max_index(_builder, _ptr)  \
+   lp_build_struct_get(_builder, _ptr, 1, "max_index")
+
+#define draw_jit_vbuffer_offset(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, 2, "buffer_offset")
 
 

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


Mesa (master): llvmpipe: No need to flush the caches for buffers.

2010-04-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 2cd128ab443addeb6e013f80d7c3f6639a66b2f1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2cd128ab443addeb6e013f80d7c3f6639a66b2f1

Author: José Fonseca 
Date:   Sun Apr 25 17:15:56 2010 +0100

llvmpipe: No need to flush the caches for buffers.

---

 src/gallium/drivers/llvmpipe/lp_flush.c |   24 +---
 src/gallium/drivers/llvmpipe/lp_flush.h |2 +-
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c 
b/src/gallium/drivers/llvmpipe/lp_flush.c
index 470132d..644b821 100644
--- a/src/gallium/drivers/llvmpipe/lp_flush.c
+++ b/src/gallium/drivers/llvmpipe/lp_flush.c
@@ -103,7 +103,7 @@ llvmpipe_flush( struct pipe_context *pipe,
  */
 boolean
 llvmpipe_flush_resource(struct pipe_context *pipe,
-struct pipe_resource *texture,
+struct pipe_resource *resource,
 unsigned face,
 unsigned level,
 unsigned flush_flags,
@@ -113,21 +113,23 @@ llvmpipe_flush_resource(struct pipe_context *pipe,
 {
unsigned referenced;
 
-   referenced = pipe->is_resource_referenced(pipe, texture, face, level);
+   referenced = pipe->is_resource_referenced(pipe, resource, face, level);
 
if ((referenced & PIPE_REFERENCED_FOR_WRITE) ||
((referenced & PIPE_REFERENCED_FOR_READ) && !read_only)) {
 
-  /*
-   * TODO: The semantics of these flush flags are too obtuse. They should
-   * disappear and the pipe driver should just ensure that all visible
-   * side-effects happen when they need to happen.
-   */
-  if (referenced & PIPE_REFERENCED_FOR_WRITE)
- flush_flags |= PIPE_FLUSH_RENDER_CACHE;
+  if (resource->target != PIPE_BUFFER) {
+ /*
+  * TODO: The semantics of these flush flags are too obtuse. They 
should
+  * disappear and the pipe driver should just ensure that all visible
+  * side-effects happen when they need to happen.
+  */
+ if (referenced & PIPE_REFERENCED_FOR_WRITE)
+flush_flags |= PIPE_FLUSH_RENDER_CACHE;
 
-  if (referenced & PIPE_REFERENCED_FOR_READ)
- flush_flags |= PIPE_FLUSH_TEXTURE_CACHE;
+ if (referenced & PIPE_REFERENCED_FOR_READ)
+flush_flags |= PIPE_FLUSH_TEXTURE_CACHE;
+  }
 
   if (cpu_access) {
  /*
diff --git a/src/gallium/drivers/llvmpipe/lp_flush.h 
b/src/gallium/drivers/llvmpipe/lp_flush.h
index 1b38820..7b60568 100644
--- a/src/gallium/drivers/llvmpipe/lp_flush.h
+++ b/src/gallium/drivers/llvmpipe/lp_flush.h
@@ -39,7 +39,7 @@ llvmpipe_flush(struct pipe_context *pipe, unsigned flags,
 
 boolean
 llvmpipe_flush_resource(struct pipe_context *pipe,
-struct pipe_resource *texture,
+struct pipe_resource *resource,
 unsigned face,
 unsigned level,
 unsigned flush_flags,

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


Mesa (master): llvmpipe: Respect pipe_sampler_view::swizzle_r/g/b/a

2010-04-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 81ab19de04e623d24cb65ad1ed3b240bce78235b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=81ab19de04e623d24cb65ad1ed3b240bce78235b

Author: José Fonseca 
Date:   Mon Apr 26 00:32:13 2010 +0100

llvmpipe: Respect pipe_sampler_view::swizzle_r/g/b/a

This allows u_sampler_view_default_dx9_template to do its magic on DX9.

---

 src/gallium/auxiliary/gallivm/lp_bld_sample.c |5 ++
 src/gallium/auxiliary/gallivm/lp_bld_sample.h |8 +++-
 src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c |   51 +
 3 files changed, 63 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c 
b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
index e1b029a..195a495 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
@@ -77,6 +77,11 @@ lp_sampler_static_state(struct lp_sampler_static_state 
*state,
 */
 
state->format= view->format;
+   state->swizzle_r = view->swizzle_r;
+   state->swizzle_g = view->swizzle_g;
+   state->swizzle_b = view->swizzle_b;
+   state->swizzle_a = view->swizzle_a;
+
state->target= texture->target;
state->pot_width = util_is_pot(texture->width0);
state->pot_height= util_is_pot(texture->height0);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h 
b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
index e287376..8ceb204 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
@@ -54,8 +54,14 @@ struct lp_build_context;
  */
 struct lp_sampler_static_state
 {
-   /* pipe_texture's state */
+   /* pipe_sampler_view's state */
enum pipe_format format;
+   unsigned swizzle_r:3;
+   unsigned swizzle_g:3;
+   unsigned swizzle_b:3;
+   unsigned swizzle_a:3;
+
+   /* pipe_texture's state */
unsigned target:3;
unsigned pot_width:1;
unsigned pot_height:1;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index 415346c..54ef921 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -185,6 +185,53 @@ texture_dims(enum pipe_texture_target tex)
 }
 
 
+static LLVMValueRef
+lp_build_swizzle_chan_soa(struct lp_type type,
+  const LLVMValueRef *unswizzled,
+  enum util_format_swizzle swizzle)
+{
+   switch (swizzle) {
+   case PIPE_SWIZZLE_RED:
+   case PIPE_SWIZZLE_GREEN:
+   case PIPE_SWIZZLE_BLUE:
+   case PIPE_SWIZZLE_ALPHA:
+  return unswizzled[swizzle];
+   case PIPE_SWIZZLE_ZERO:
+  return lp_build_zero(type);
+   case PIPE_SWIZZLE_ONE:
+  return lp_build_one(type);
+   default:
+  assert(0);
+  return lp_build_undef(type);
+   }
+}
+
+
+static void
+lp_build_swizzle_soa(struct lp_build_sample_context *bld,
+ LLVMValueRef *texel)
+{
+   LLVMValueRef unswizzled[4];
+   unsigned char swizzles[4];
+   unsigned chan;
+
+   for (chan = 0; chan < 4; ++chan) {
+  unswizzled[chan] = texel[chan];
+   }
+
+   swizzles[0] = bld->static_state->swizzle_r;
+   swizzles[1] = bld->static_state->swizzle_g;
+   swizzles[2] = bld->static_state->swizzle_b;
+   swizzles[3] = bld->static_state->swizzle_a;
+
+   for (chan = 0; chan < 4; ++chan) {
+  unsigned swizzle = swizzles[chan];
+  texel[chan] = lp_build_swizzle_chan_soa(bld->texel_type,
+  unswizzled, swizzle);
+   }
+}
+
+
 
 /**
  * Generate code to fetch a texel from a texture at int coords (x, y, z).
@@ -285,6 +332,8 @@ lp_build_sample_texel_soa(struct lp_build_sample_context 
*bld,
i, j,
texel);
 
+   lp_build_swizzle_soa(bld, texel);
+
/*
 * Note: if we find an app which frequently samples the texture border
 * we might want to implement a true conditional here to avoid sampling
@@ -1954,6 +2003,8 @@ lp_build_sample_2d_linear_aos(struct 
lp_build_sample_context *bld,
lp_build_format_swizzle_soa(bld->format_desc,
bld->texel_type, unswizzled,
texel);
+
+   lp_build_swizzle_soa(bld, texel);
 }
 
 

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


Mesa (master): draw: Always use the llvm middle end when available & enabled.

2010-04-26 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 6ecbbc3c056d177174c97ac4d1a57abed3ac3177
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6ecbbc3c056d177174c97ac4d1a57abed3ac3177

Author: José Fonseca 
Date:   Mon Apr 26 15:31:37 2010 +0100

draw: Always use the llvm middle end when available & enabled.

---

 src/gallium/auxiliary/draw/draw_private.h |3 +-
 src/gallium/auxiliary/draw/draw_pt.c  |   37 
 2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_private.h 
b/src/gallium/auxiliary/draw/draw_private.h
index 4bb3282..a2bfb69 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -132,6 +132,7 @@ struct draw_context
  struct draw_pt_middle_end *fetch_emit;
  struct draw_pt_middle_end *fetch_shade_emit;
  struct draw_pt_middle_end *general;
+ struct draw_pt_middle_end *llvm;
   } middle;
 
   struct {
@@ -253,8 +254,8 @@ struct draw_context
 
 #ifdef HAVE_LLVM
LLVMExecutionEngineRef engine;
-   boolean use_llvm;
 #endif
+
void *driver_private;
 };
 
diff --git a/src/gallium/auxiliary/draw/draw_pt.c 
b/src/gallium/auxiliary/draw/draw_pt.c
index c40c25d..1d9395e 100644
--- a/src/gallium/auxiliary/draw/draw_pt.c
+++ b/src/gallium/auxiliary/draw/draw_pt.c
@@ -97,12 +97,16 @@ draw_pt_arrays(struct draw_context *draw,
   opt |= PT_SHADE;
}
   
-   if (opt == 0) 
-  middle = draw->pt.middle.fetch_emit;
-   else if (opt == PT_SHADE && !draw->pt.no_fse)
-  middle = draw->pt.middle.fetch_shade_emit;
-   else
-  middle = draw->pt.middle.general;
+   if (draw->pt.middle.llvm) {
+  middle = draw->pt.middle.llvm;
+   } else {
+  if (opt == 0)
+ middle = draw->pt.middle.fetch_emit;
+  else if (opt == PT_SHADE && !draw->pt.no_fse)
+ middle = draw->pt.middle.fetch_shade_emit;
+  else
+ middle = draw->pt.middle.general;
+   }
 
 
/* Pick the right frontend
@@ -148,25 +152,26 @@ boolean draw_pt_init( struct draw_context *draw )
if (!draw->pt.middle.fetch_shade_emit)
   return FALSE;
 
-#if HAVE_LLVM
-   draw->use_llvm = debug_get_option_draw_use_llvm();
-   if (draw->use_llvm)
-  draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit_llvm( draw );
-#else
-   draw->pt.middle.general = NULL;
-#endif
-
-   if (!draw->pt.middle.general)
-  draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit( draw );
+   draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit( draw );
if (!draw->pt.middle.general)
   return FALSE;
 
+#if HAVE_LLVM
+   if (debug_get_option_draw_use_llvm())
+  draw->pt.middle.llvm = draw_pt_fetch_pipeline_or_emit_llvm( draw );
+#endif
+
return TRUE;
 }
 
 
 void draw_pt_destroy( struct draw_context *draw )
 {
+   if (draw->pt.middle.llvm) {
+  draw->pt.middle.llvm->destroy( draw->pt.middle.llvm );
+  draw->pt.middle.llvm = NULL;
+   }
+
if (draw->pt.middle.general) {
   draw->pt.middle.general->destroy( draw->pt.middle.general );
   draw->pt.middle.general = NULL;

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


Mesa (master): translate: Take and respect a max_index argument.

2010-04-26 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: fc431a58dc1446383edc11aec2a0b7de5b363e5e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc431a58dc1446383edc11aec2a0b7de5b363e5e

Author: José Fonseca 
Date:   Mon Apr 26 14:49:42 2010 +0100

translate: Take and respect a max_index argument.

---

 src/gallium/auxiliary/translate/translate.h|3 ++-
 .../auxiliary/translate/translate_generic.c|   19 +--
 src/gallium/auxiliary/translate/translate_sse.c|   10 +-
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/src/gallium/auxiliary/translate/translate.h 
b/src/gallium/auxiliary/translate/translate.h
index 54ed2c1..edd95e0 100644
--- a/src/gallium/auxiliary/translate/translate.h
+++ b/src/gallium/auxiliary/translate/translate.h
@@ -76,7 +76,8 @@ struct translate {
void (*set_buffer)( struct translate *,
   unsigned i,
   const void *ptr,
-  unsigned stride );
+  unsigned stride,
+  unsigned max_index );
 
void (PIPE_CDECL *run_elts)( struct translate *,
 const unsigned *elts,
diff --git a/src/gallium/auxiliary/translate/translate_generic.c 
b/src/gallium/auxiliary/translate/translate_generic.c
index c3ec9ae..a9272fb 100644
--- a/src/gallium/auxiliary/translate/translate_generic.c
+++ b/src/gallium/auxiliary/translate/translate_generic.c
@@ -31,6 +31,7 @@
   */
 
 #include "util/u_memory.h"
+#include "util/u_math.h"
 #include "pipe/p_state.h"
 #include "translate.h"
 
@@ -58,6 +59,7 @@ struct translate_generic {
   
   char *input_ptr;
   unsigned input_stride;
+  unsigned max_index;
 
} attrib[PIPE_MAX_ATTRIBS];
 
@@ -588,19 +590,22 @@ static void PIPE_CDECL generic_run_elts( struct translate 
*translate,
   for (attr = 0; attr < nr_attrs; attr++) {
 float data[4];
  const char *src;
+ unsigned index;
 
 char *dst = (vert + 
  tg->attrib[attr].output_offset);
 
  if (tg->attrib[attr].instance_divisor) {
-src = tg->attrib[attr].input_ptr +
-  tg->attrib[attr].input_stride *
-  (instance_id / tg->attrib[attr].instance_divisor);
+index = instance_id / tg->attrib[attr].instance_divisor;
  } else {
-src = tg->attrib[attr].input_ptr +
-  tg->attrib[attr].input_stride * elt;
+index = elt;
  }
 
+ index = MIN2(index, tg->attrib[attr].max_index);
+
+ src = tg->attrib[attr].input_ptr +
+   tg->attrib[attr].input_stride * index;
+
 tg->attrib[attr].fetch( src, data );
 
  if (0) debug_printf("vert %d/%d attr %d: %f %f %f %f\n",
@@ -670,7 +675,8 @@ static void PIPE_CDECL generic_run( struct translate 
*translate,
 static void generic_set_buffer( struct translate *translate,
unsigned buf,
const void *ptr,
-   unsigned stride )
+   unsigned stride,
+   unsigned max_index )
 {
struct translate_generic *tg = translate_generic(translate);
unsigned i;
@@ -680,6 +686,7 @@ static void generic_set_buffer( struct translate *translate,
 tg->attrib[i].input_ptr = ((char *)ptr +
tg->attrib[i].input_offset);
 tg->attrib[i].input_stride = stride;
+ tg->attrib[i].max_index = max_index;
   }
}
 }
diff --git a/src/gallium/auxiliary/translate/translate_sse.c 
b/src/gallium/auxiliary/translate/translate_sse.c
index c13e742..ef3aa67 100644
--- a/src/gallium/auxiliary/translate/translate_sse.c
+++ b/src/gallium/auxiliary/translate/translate_sse.c
@@ -61,6 +61,7 @@ typedef void (PIPE_CDECL *run_elts_func)( struct translate 
*translate,
 struct translate_buffer {
const void *base_ptr;
unsigned stride;
+   unsigned max_index;
 };
 
 struct translate_buffer_varient {
@@ -423,6 +424,11 @@ static boolean init_inputs( struct translate_sse *p,
  } else {
 x86_mov(p->func, tmp_EAX, elt);
  }
+
+ /*
+  * TODO: Respect translate_buffer::max_index.
+  */
+
  x86_imul(p->func, tmp_EAX, buf_stride);
  x86_add(p->func, tmp_EAX, buf_base_ptr);
 
@@ -666,13 +672,15 @@ static boolean build_vertex_emit( struct translate_sse *p,
 static void translate_sse_set_buffer( struct translate *translate,
unsigned buf,
const void *ptr,
-   unsigned stride )
+   unsigned stride,
+   unsigned max_index )
 {
struct translate_sse *p = (struct translate_sse *)translate;
 
if (buf < p->nr_buffers) {
   p->buffer[buf].base_ptr = (char *)ptr;
   p->buffer[buf].stride = stride;
+  p->buffer[b

<    1   2   3   4   5   6   7   8   9   10   >