Hash :
70961b33
Author :
Date :
2013-05-30T00:17:48
Add support for structures in interface and uniform blocks. Also redesigns the uniform block layout computation to be more general. TRAC #23018 Signed-off-by: Geoff Lang Signed-off-by: Nicolas Capens Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2387 736b8ea6-26fd-11df-bfd4-992fa37f6226
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
//
// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#ifndef COMPILER_UNIFORM_H_
#define COMPILER_UNIFORM_H_
#include <string>
#include <vector>
#define GL_APICALL
#include <GLES3/gl3.h>
#include <GLES2/gl2.h>
namespace sh
{
struct Uniform
{
Uniform(GLenum type, GLenum precision, const char *name, unsigned int arraySize, unsigned int registerIndex);
GLenum type;
GLenum precision;
std::string name;
unsigned int arraySize;
unsigned int registerIndex;
std::vector<Uniform> fields;
};
typedef std::vector<Uniform> ActiveUniforms;
struct BlockMemberInfo
{
BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix);
int offset;
int arrayStride;
int matrixStride;
bool isRowMajorMatrix;
static const BlockMemberInfo defaultBlockInfo;
};
typedef std::vector<BlockMemberInfo> BlockMemberInfoArray;
enum BlockLayoutType
{
BLOCKLAYOUT_STANDARD,
BLOCKLAYOUT_PACKED,
BLOCKLAYOUT_SHARED
};
struct InterfaceBlock
{
InterfaceBlock(const char *name, unsigned int arraySize, unsigned int registerIndex);
std::string name;
unsigned int arraySize;
ActiveUniforms activeUniforms;
size_t dataSize;
std::vector<BlockMemberInfo> blockInfo;
BlockLayoutType layout;
unsigned int registerIndex;
void setBlockLayout(BlockLayoutType newLayout);
private:
void getBlockLayoutInfo(const sh::ActiveUniforms &fields, unsigned int *currentOffset);
bool getBlockLayoutInfo(const sh::Uniform &uniform, unsigned int *currentOffset, int *arrayStrideOut, int *matrixStrideOut);
void getD3DLayoutInfo(const sh::Uniform &uniform, unsigned int *currentOffset, int *arrayStrideOut, int *matrixStrideOut);
void getStandardLayoutInfo(const sh::Uniform &uniform, unsigned int *currentOffset, int *arrayStrideOut, int *matrixStrideOut);
};
typedef std::vector<InterfaceBlock> ActiveInterfaceBlocks;
}
#endif // COMPILER_UNIFORM_H_