/*assert(!var->declared);*/
var->declared = GL_TRUE;
- if(is_sampler_type(&var->type)) {
- slang_info_log_error(A->log, "redeclaration of sampler '%s'",
- (char*) var->a_name);
- return NULL;
- }
-
n = new_node0(IR_VAR_DECL);
if (n) {
_slang_attach_storage(n, var);
assert(n->Store);
assert(n->Store->Index < 0);
- n->Store->File = PROGRAM_TEMPORARY;
+ if (is_sampler_type(&var->type)) {
+ n->Store->File = PROGRAM_SAMPLER;
+ }
+ else {
+ n->Store->File = PROGRAM_TEMPORARY;
+ }
+
n->Store->Size = _slang_sizeof_type_specifier(&n->Var->type.specifier);
if (n->Store->Size <= 0) {
n->Store = n->Children[0]->Store;
+ if (n->Store->File == PROGRAM_SAMPLER) {
+ /* no code generated for sampler assignments,
+ * just copy the sampler index at compile time.
+ */
+ n->Store->Index = n->Children[1]->Store->Index;
+ return NULL;
+ }
+
#if PEEPHOLE_OPTIMIZATIONS
if (inst &&
_slang_is_temp(emitInfo->vt, n->Children[1]->Store) &&
store->Index,
_mesa_swizzle_string(store->Swizzle, 0, 0));
+ if (store->File == PROGRAM_SAMPLER) {
+ /* samplers have no storage */
+ continue;
+ }
+
if (store->Size == 1)
comp = GET_SWZ(store->Swizzle, 0);
else
_slang_alloc_var(slang_var_table *vt, slang_ir_storage *store)
{
struct table *t = vt->Top;
- const int i = alloc_reg(vt, store->Size, GL_FALSE);
+ int i;
+
+ if (store->File == PROGRAM_SAMPLER) {
+ /* don't really allocate storage */
+ store->Index = 0;
+ return GL_TRUE;
+ }
+
+ i = alloc_reg(vt, store->Size, GL_FALSE);
if (i < 0)
return GL_FALSE;