Fix nested conditionals

This commit is contained in:
Zack Rusin 2007-10-25 07:52:59 -04:00
parent e842b5e5ba
commit 1d26e9c447
5 changed files with 25 additions and 13 deletions

View File

@ -0,0 +1,13 @@
void main() {
gl_Position = gl_Vertex;
if (gl_Position.x < 0.5) {
if (gl_Position.y < 0.20) {
gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0);
} else {
gl_FrontColor = vec4(0.0, 1.0, 0.0, 1.0);
}
gl_FrontColor.y = 1.0;
} else
gl_FrontColor = gl_Color;
}

View File

@ -0,0 +1,9 @@
void main() {
gl_Position = gl_Vertex;
gl_FrontColor = gl_Color;
if (gl_Position.x < 0.5) {
gl_FrontColor.y = 1.0;
}
gl_FrontColor.xzw = vec3(0, 0, 1);
}

View File

@ -54,7 +54,7 @@ static void read_shader(GLuint shader, const char *filename)
}
n = fread(buffer, 1, max, f);
printf("fslight: read %d bytes from shader file %s\n", n, filename);
printf("vp-tris: read %d bytes from shader file %s\n", n, filename);
if (n > 0) {
buffer[n] = 0;
load_and_compile_shader(shader, buffer);

View File

@ -123,9 +123,6 @@ llvm::ConstantInt *Storage::constantInt(int idx)
llvm::Value *Storage::inputElement(int idx, llvm::Value *indIdx)
{
if (!indIdx && m_inputs.find(idx) != m_inputs.end()) {
return m_inputs[idx];
}
GetElementPtrInst *getElem = 0;
if (indIdx) {
@ -147,7 +144,6 @@ llvm::Value *Storage::inputElement(int idx, llvm::Value *indIdx)
LoadInst *load = new LoadInst(getElem, name("input"),
false, m_block);
load->setAlignment(8);
m_inputs[idx] = load;
return load;
}
@ -155,9 +151,6 @@ llvm::Value *Storage::inputElement(int idx, llvm::Value *indIdx)
llvm::Value *Storage::constElement(int idx, llvm::Value *indIdx)
{
m_numConsts = ((idx + 1) > m_numConsts) ? (idx + 1) : m_numConsts;
if (!indIdx && m_consts.find(idx) != m_consts.end()) {
return m_consts[idx];
}
GetElementPtrInst *getElem = 0;
@ -178,7 +171,6 @@ llvm::Value *Storage::constElement(int idx, llvm::Value *indIdx)
LoadInst *load = new LoadInst(getElem, name("const"),
false, m_block);
load->setAlignment(8);
m_consts[idx] = load;
return load;
}
@ -334,7 +326,6 @@ llvm::Value * Storage::outputElement(int idx, llvm::Value *indIdx )
LoadInst *load = new LoadInst(getElem, name("output"),
false, m_block);
load->setAlignment(8);
m_inputs[idx] = load;
return load;
}

View File

@ -47,7 +47,6 @@ namespace llvm {
class Storage
{
typedef std::map<int, llvm::LoadInst*> LoadMap;
public:
Storage(llvm::BasicBlock *block,
llvm::Value *out,
@ -75,9 +74,11 @@ public:
void store(int dstIdx, llvm::Value *val, int mask);
int numConsts() const;
private:
llvm::Value *maskWrite(llvm::Value *src, int mask, llvm::Value *templ);
const char *name(const char *prefix);
private:
llvm::BasicBlock *m_block;
llvm::Value *m_OUT;
@ -89,8 +90,6 @@ private:
std::vector<llvm::Value*> m_temps;
std::vector<llvm::Value*> m_addrs;
std::vector<llvm::Value*> m_dstCache;
LoadMap m_inputs;
LoadMap m_consts;
llvm::VectorType *m_floatVecType;
llvm::VectorType *m_intVecType;