diff options
author | Brian Paul <[email protected]> | 2008-12-16 14:29:52 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-12-16 14:29:52 -0700 |
commit | 368df1615ef65afed96a44e1f43ade8cc703696f (patch) | |
tree | c45fe7f9e6d6d59ef1669e573955f19c2c97a220 /src/mesa/shader/slang/slang_emit.c | |
parent | 702b5b076b7591560e7e701e0c9ff2eeb30fa966 (diff) |
mesa: fix some GLSL array regressions
array.length() wasn't working.
Swizzle mask for accessing elements of float arrays was incorrect.
Diffstat (limited to 'src/mesa/shader/slang/slang_emit.c')
-rw-r--r-- | src/mesa/shader/slang/slang_emit.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index e3cb252a3d7..6587f9cf276 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 7.1 * * Copyright (C) 2005-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2008 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"), @@ -155,6 +155,28 @@ _slang_swizzle_swizzle(GLuint swz1, GLuint swz2) /** + * Return the default swizzle mask for accessing a variable of the + * given size (in floats). If size = 1, comp is used to identify + * which component [0..3] of the register holds the variable. + */ +GLuint +_slang_var_swizzle(GLint size, GLint comp) +{ + switch (size) { + case 1: + return MAKE_SWIZZLE4(comp, comp, comp, comp); + case 2: + return MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_NIL, SWIZZLE_NIL); + case 3: + return MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_NIL); + default: + return SWIZZLE_XYZW; + } +} + + + +/** * Allocate storage for the given node (if it hasn't already been allocated). * * Typically this is temporary storage for an intermediate result (such as @@ -1917,6 +1939,7 @@ emit_array_element(slang_emit_info *emitInfo, slang_ir_node *n) } n->Store->Size = elemSize; + n->Store->Swizzle = _slang_var_swizzle(elemSize, 0); return NULL; /* no instruction */ } |