--- /dev/null
+
+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;
+}
--- /dev/null
+
+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);
+}
}
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);
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) {
LoadInst *load = new LoadInst(getElem, name("input"),
false, m_block);
load->setAlignment(8);
- m_inputs[idx] = load;
return load;
}
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;
LoadInst *load = new LoadInst(getElem, name("const"),
false, m_block);
load->setAlignment(8);
- m_consts[idx] = load;
return load;
}
LoadInst *load = new LoadInst(getElem, name("output"),
false, m_block);
load->setAlignment(8);
- m_inputs[idx] = load;
return load;
}
class Storage
{
- typedef std::map<int, llvm::LoadInst*> LoadMap;
public:
Storage(llvm::BasicBlock *block,
llvm::Value *out,
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;
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;