summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-01-14 11:58:45 -0700
committerBrian Paul <brianp@vmware.com>2009-01-14 11:58:45 -0700
commitb5f89e5f17bdf718d1f1f29e7a10dee3809c9f29 (patch)
treeabedcbb279e20649a56707f41c857f9891841bd1 /src
parentc12d24b513a67648c30bf892964f887fad71e103 (diff)
glsl: simplify IR storage for samplers
Don't overload the Size field with the texture target, to avoid confusion.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c2
-rw-r--r--src/mesa/shader/slang/slang_emit.c10
-rw-r--r--src/mesa/shader/slang/slang_ir.c22
-rw-r--r--src/mesa/shader/slang/slang_ir.h13
4 files changed, 34 insertions, 13 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index b046cc2402..211260449a 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -4293,7 +4293,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
#endif
{
GLint sampNum = _mesa_add_sampler(prog->Parameters, varName, datatype);
- store = _slang_new_ir_storage(PROGRAM_SAMPLER, sampNum, texIndex);
+ store = _slang_new_ir_storage_sampler(sampNum, texIndex, totalSize);
/* If we have a sampler array, then we need to allocate the
* additional samplers to ensure we don't allocate them elsewhere.
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index 08b7d519a5..414d3e639b 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -1300,14 +1300,10 @@ emit_tex(slang_emit_info *emitInfo, slang_ir_node *n)
NULL,
NULL);
- /* Store->Index is the sampler index */
+ /* Store->Index is the uniform/sampler index */
assert(n->Children[0]->Store->Index >= 0);
- /* Store->Size is the texture target */
- assert(n->Children[0]->Store->Size >= TEXTURE_1D_INDEX);
- assert(n->Children[0]->Store->Size <= TEXTURE_RECT_INDEX);
-
- inst->TexSrcTarget = n->Children[0]->Store->Size;
- inst->TexSrcUnit = n->Children[0]->Store->Index; /* i.e. uniform's index */
+ inst->TexSrcUnit = n->Children[0]->Store->Index;
+ inst->TexSrcTarget = n->Children[0]->Store->TexTarget;
/* mark the sampler as being used */
_mesa_use_uniform(emitInfo->prog->Parameters,
diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c
index c33c80da99..e4c6e0ea51 100644
--- a/src/mesa/shader/slang/slang_ir.c
+++ b/src/mesa/shader/slang/slang_ir.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
*
* Copyright (C) 2005-2008 Brian Paul All Rights Reserved.
+ * Copyright (C) 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"),
@@ -216,6 +216,26 @@ _slang_new_ir_storage_indirect(enum register_file file,
}
+/**
+ * Allocate IR storage for a texture sampler.
+ * \param sampNum the sampler number/index
+ * \param texTarget one of TEXTURE_x_INDEX values
+ * \param size number of samplers (in case of sampler array)
+ */
+slang_ir_storage *
+_slang_new_ir_storage_sampler(GLint sampNum, GLuint texTarget, GLint size)
+{
+ slang_ir_storage *st;
+ assert(texTarget < NUM_TEXTURE_TARGETS);
+ st = _slang_new_ir_storage(PROGRAM_SAMPLER, sampNum, size);
+ if (st) {
+ st->TexTarget = texTarget;
+ }
+ return st;
+}
+
+
+
/* XXX temporary function */
void
_slang_copy_ir_storage(slang_ir_storage *dst, const slang_ir_storage *src)
diff --git a/src/mesa/shader/slang/slang_ir.h b/src/mesa/shader/slang/slang_ir.h
index a258e92e06..644269d491 100644
--- a/src/mesa/shader/slang/slang_ir.h
+++ b/src/mesa/shader/slang/slang_ir.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.3
*
- * Copyright (C) 2005-2007 Brian Paul All Rights Reserved.
+ * Copyright (C) 2005-2008 Brian Paul All Rights Reserved.
+ * Copyright (C) 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"),
@@ -168,8 +168,8 @@ typedef enum
struct slang_ir_storage_
{
enum register_file File; /**< PROGRAM_TEMPORARY, PROGRAM_INPUT, etc */
- GLint Index; /**< -1 means unallocated */
- GLint Size; /**< number of floats */
+ GLint Index; /**< -1 means unallocated */
+ GLint Size; /**< number of floats or ints */
GLuint Swizzle; /**< Swizzle AND writemask info */
GLint RefCount; /**< Used during IR tree delete */
@@ -179,6 +179,7 @@ struct slang_ir_storage_
enum register_file IndirectFile;
GLint IndirectIndex;
GLuint IndirectSwizzle;
+ GLuint TexTarget; /**< If File==PROGRAM_SAMPLER, one of TEXTURE_x_INDEX */
/** If Parent is non-null, Index is relative to parent.
* The other fields are ignored.
@@ -254,6 +255,10 @@ _slang_new_ir_storage_indirect(enum register_file file,
GLint indirectIndex,
GLuint indirectSwizzle);
+extern slang_ir_storage *
+_slang_new_ir_storage_sampler(GLint sampNum, GLuint texTarget, GLint size);
+
+
extern void
_slang_copy_ir_storage(slang_ir_storage *dst, const slang_ir_storage *src);