diff options
author | Brian Paul <[email protected]> | 2008-12-30 17:11:32 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-12-30 17:11:32 -0700 |
commit | c6537ac8b8130cf2271c8d1e51137a575073c762 (patch) | |
tree | d51e85841d71823d778a61ade9890af7bf4f24c2 /src/mesa/shader/slang/library/slang_common_builtin.gc | |
parent | ca0540e25c86b8095511868b0cbe96d7e85f7437 (diff) |
mesa: allow variable indexing into the predefined uniform variable arrays
This allows code such as "vec4 a = gl_LightSource[i].ambient;" to work.
When a built-in uniform array is indexed with a variable index we need to
"unroll" the whole array into the parameter list (aka constant buffer) because
we don't know which elements may be accessed at compile-time. In the case of
the gl_LightSource array of size [8], we emit 64 state references into the
parameter array (8 elements times 8 vec4s per gl_LightSourceParameters
struct).
Previously, we only allowed constant-indexed references to uniform arrays
(such as gl_LightSource[2].position) which resulted in a single state reference
being added to the parameter array, not 64. We still optimize this case.
Users should be aware that using "gl_LightSource[i].ambient" in their shaders
is a bit expensive since state validation will involve updating all 64
light source entries in the parameter list.
Diffstat (limited to 'src/mesa/shader/slang/library/slang_common_builtin.gc')
-rw-r--r-- | src/mesa/shader/slang/library/slang_common_builtin.gc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mesa/shader/slang/library/slang_common_builtin.gc b/src/mesa/shader/slang/library/slang_common_builtin.gc index a051c53eea3..3e03b101b87 100644 --- a/src/mesa/shader/slang/library/slang_common_builtin.gc +++ b/src/mesa/shader/slang/library/slang_common_builtin.gc @@ -1,8 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.3 * * Copyright (C) 2006 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"), @@ -98,6 +99,9 @@ struct gl_MaterialParameters { uniform gl_MaterialParameters gl_FrontMaterial; uniform gl_MaterialParameters gl_BackMaterial; +/* NOTE: the order of these fields is significant! + * See the definition of the lighting state vars such as STATE_SPOT_DIRECTION. + */ struct gl_LightSourceParameters { vec4 ambient; vec4 diffuse; @@ -105,12 +109,14 @@ struct gl_LightSourceParameters { vec4 position; vec4 halfVector; vec3 spotDirection; - float spotExponent; - float spotCutoff; float spotCosCutoff; + float constantAttenuation; float linearAttenuation; float quadraticAttenuation; + float spotExponent; + + float spotCutoff; }; uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights]; |