blob: 7b286653932f7fa8c08261937943f67c9d013b81 [file] [log] [blame]
daniel@transgaming.com15186aa2012-12-20 21:08:23 +00001//
2// Copyright (c) 2010-2012 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7#ifndef LIBGLESV2_UNIFORM_H_
8#define LIBGLESV2_UNIFORM_H_
9
10#include <string>
11
12#define GL_APICALL
13#include <GLES2/gl2.h>
14
15#include "common/debug.h"
16#include "libGLESv2/renderer/D3DConstantTable.h"
17
18namespace gl
19{
20
21// Helper struct representing a single shader uniform
22struct Uniform
23{
24 Uniform(GLenum type, const std::string &_name, unsigned int arraySize);
25
26 ~Uniform();
27
28 bool isArray();
29 static std::string Uniform::undecorate(const std::string &_name);
30
31 const GLenum type;
32 const std::string _name; // Decorated name
33 const std::string name; // Undecorated name
34 const unsigned int arraySize;
35
36 unsigned char *data;
37 bool dirty;
38
39 struct RegisterInfo
40 {
41 RegisterInfo()
42 {
43 float4Index = -1;
44 samplerIndex = -1;
45 boolIndex = -1;
46 registerCount = 0;
47 }
48
49 void set(const rx::D3DConstant *constant)
50 {
51 switch(constant->registerSet)
52 {
53 case rx::D3DConstant::RS_BOOL: boolIndex = constant->registerIndex; break;
54 case rx::D3DConstant::RS_FLOAT4: float4Index = constant->registerIndex; break;
55 case rx::D3DConstant::RS_SAMPLER: samplerIndex = constant->registerIndex; break;
56 default: UNREACHABLE();
57 }
58
59 ASSERT(registerCount == 0 || registerCount == (int)constant->registerCount);
60 registerCount = constant->registerCount;
61 }
62
63 int float4Index;
64 int samplerIndex;
65 int boolIndex;
66
67 int registerCount;
68 };
69
70 RegisterInfo ps;
71 RegisterInfo vs;
72};
73
74typedef std::vector<Uniform*> UniformArray;
75
76}
77
78#endif // LIBGLESV2_UNIFORM_H_