glsl: simplify IR storage for samplers
Don't overload the Size field with the texture target, to avoid confusion.
This commit is contained in:
parent
c12d24b513
commit
b5f89e5f17
|
@ -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.
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue