Reflection: Add translation from glslang types to the API #define types.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24042 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
568bc3ae55
commit
ec252dfd3b
@ -8,54 +8,60 @@ Linked vertex stage:
|
||||
|
||||
|
||||
Uniform reflection:
|
||||
0: anonMember3: offset 80, type 35666, arraySize 1, index 0
|
||||
1: s.a: offset -1, type 35666, arraySize 1, index -1
|
||||
2: ablock.scalar: offset 12, type 35666, arraySize 1, index 1
|
||||
3: m23: offset 16, type 35666, arraySize 1, index 0
|
||||
4: scalarAfterm23: offset 48, type 35666, arraySize 1, index 0
|
||||
5: c_m23: offset 16, type 35666, arraySize 1, index 2
|
||||
6: c_scalarAfterm23: offset 64, type 35666, arraySize 1, index 2
|
||||
7: scalarBeforeArray: offset 96, type 35666, arraySize 1, index 0
|
||||
8: floatArray: offset 112, type 35666, arraySize 5, index 0
|
||||
9: scalarAfterArray: offset 192, type 35666, arraySize 1, index 0
|
||||
10: ablock.memvec2: offset 48, type 35666, arraySize 1, index 1
|
||||
11: ablock.memf1: offset 56, type 35666, arraySize 1, index 1
|
||||
12: ablock.memf2: offset 60, type 35666, arraySize 1, index 1
|
||||
13: ablock.memf3: offset 64, type 35666, arraySize 1, index 1
|
||||
14: ablock.memvec2a: offset 72, type 35666, arraySize 1, index 1
|
||||
15: anonMember1: offset 0, type 35666, arraySize 1, index 0
|
||||
16: uf1: offset -1, type 35666, arraySize 1, index -1
|
||||
17: uf2: offset -1, type 35666, arraySize 1, index -1
|
||||
18: ablock.member3: offset 32, type 35666, arraySize 1, index 1
|
||||
0: image_ui2D: offset -1, type 9063, arraySize 1, index -1
|
||||
1: sampler_2D: offset -1, type 8b5e, arraySize 1, index -1
|
||||
2: sampler_2DMSArray: offset -1, type 910b, arraySize 1, index -1
|
||||
3: anonMember3: offset 80, type 8b52, arraySize 1, index 0
|
||||
4: s.a: offset -1, type 1404, arraySize 1, index -1
|
||||
5: ablock.scalar: offset 12, type 1404, arraySize 1, index 1
|
||||
6: m23: offset 16, type 8b67, arraySize 1, index 0
|
||||
7: scalarAfterm23: offset 48, type 1404, arraySize 1, index 0
|
||||
8: c_m23: offset 16, type 8b67, arraySize 1, index 2
|
||||
9: c_scalarAfterm23: offset 64, type 1404, arraySize 1, index 2
|
||||
10: scalarBeforeArray: offset 96, type 1404, arraySize 1, index 0
|
||||
11: floatArray: offset 112, type 1406, arraySize 5, index 0
|
||||
12: scalarAfterArray: offset 192, type 1404, arraySize 1, index 0
|
||||
13: ablock.memvec2: offset 48, type 8b50, arraySize 1, index 1
|
||||
14: ablock.memf1: offset 56, type 1406, arraySize 1, index 1
|
||||
15: ablock.memf2: offset 60, type 8b56, arraySize 1, index 1
|
||||
16: ablock.memf3: offset 64, type 1404, arraySize 1, index 1
|
||||
17: ablock.memvec2a: offset 72, type 8b50, arraySize 1, index 1
|
||||
18: anonMember1: offset 0, type 8b51, arraySize 1, index 0
|
||||
19: uf1: offset -1, type 1406, arraySize 1, index -1
|
||||
20: uf2: offset -1, type 1406, arraySize 1, index -1
|
||||
21: ablock.member3: offset 32, type 8b52, arraySize 1, index 1
|
||||
|
||||
Uniform block reflection:
|
||||
0: nameless: offset -1, type -1, arraySize 1, index -1
|
||||
1: ablock: offset -1, type -1, arraySize 1, index -1
|
||||
2: c_nameless: offset -1, type -1, arraySize 1, index -1
|
||||
0: nameless: offset -1, type ffffffff, arraySize 1, index -1
|
||||
1: ablock: offset -1, type ffffffff, arraySize 1, index -1
|
||||
2: c_nameless: offset -1, type ffffffff, arraySize 1, index -1
|
||||
|
||||
Live names
|
||||
ablock: 1
|
||||
ablock.member3: 18
|
||||
ablock.memf1: 11
|
||||
ablock.memf2: 12
|
||||
ablock.memf3: 13
|
||||
ablock.memvec2: 10
|
||||
ablock.memvec2a: 14
|
||||
ablock.scalar: 2
|
||||
anonMember1: 15
|
||||
anonMember3: 0
|
||||
c_m23: 5
|
||||
ablock.member3: 21
|
||||
ablock.memf1: 14
|
||||
ablock.memf2: 15
|
||||
ablock.memf3: 16
|
||||
ablock.memvec2: 13
|
||||
ablock.memvec2a: 17
|
||||
ablock.scalar: 5
|
||||
anonMember1: 18
|
||||
anonMember3: 3
|
||||
c_m23: 8
|
||||
c_nameless: 2
|
||||
c_scalarAfterm23: 6
|
||||
floatArray: 8
|
||||
liveFunction1(: -1
|
||||
c_scalarAfterm23: 9
|
||||
floatArray: 11
|
||||
image_ui2D: 0
|
||||
liveFunction1(uI21;s21;sA21;: -1
|
||||
liveFunction2(: -1
|
||||
m23: 3
|
||||
m23: 6
|
||||
nameless: 0
|
||||
s.a: 1
|
||||
scalarAfterArray: 9
|
||||
scalarAfterm23: 4
|
||||
scalarBeforeArray: 7
|
||||
uf1: 16
|
||||
uf2: 17
|
||||
s.a: 4
|
||||
sampler_2D: 1
|
||||
sampler_2DMSArray: 2
|
||||
scalarAfterArray: 12
|
||||
scalarAfterm23: 7
|
||||
scalarBeforeArray: 10
|
||||
uf1: 19
|
||||
uf2: 20
|
||||
|
||||
|
@ -51,6 +51,10 @@ uniform float uf2;
|
||||
uniform float ufDead3;
|
||||
uniform float ufDead4;
|
||||
|
||||
uniform uimage2D image_ui2D;
|
||||
uniform sampler2D sampler_2D;
|
||||
uniform sampler2DMSArray sampler_2DMSArray;
|
||||
|
||||
const bool control = true;
|
||||
|
||||
void deadFunction()
|
||||
@ -66,7 +70,8 @@ void liveFunction2()
|
||||
float f = uf1;
|
||||
}
|
||||
|
||||
void liveFunction1()
|
||||
void liveFunction1(uimage2D p_ui2D, sampler2D p_2D, sampler2DMSArray p_2DMSArray)
|
||||
|
||||
{
|
||||
liveFunction2();
|
||||
float f = uf2;
|
||||
@ -75,7 +80,7 @@ void liveFunction1()
|
||||
|
||||
void main()
|
||||
{
|
||||
liveFunction1();
|
||||
liveFunction1(image_ui2D, sampler_2D, sampler_2DMSArray);
|
||||
liveFunction2();
|
||||
|
||||
if (! control)
|
||||
|
150
glslang/MachineIndependent/gl_types.h
Normal file
150
glslang/MachineIndependent/gl_types.h
Normal file
@ -0,0 +1,150 @@
|
||||
/*
|
||||
** Copyright (c) 2013 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
** "Materials"), to deal in the Materials without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
** permit persons to whom the Materials are furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included
|
||||
** in all copies or substantial portions of the Materials.
|
||||
**
|
||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
#define GL_FLOAT 0x1406
|
||||
#define GL_FLOAT_VEC2 0x8B50
|
||||
#define GL_FLOAT_VEC3 0x8B51
|
||||
#define GL_FLOAT_VEC4 0x8B52
|
||||
|
||||
#define GL_DOUBLE 0x140A
|
||||
#define GL_DOUBLE_VEC2 0x8FFC
|
||||
#define GL_DOUBLE_VEC3 0x8FFD
|
||||
#define GL_DOUBLE_VEC4 0x8FFE
|
||||
|
||||
#define GL_INT 0x1404
|
||||
#define GL_INT_VEC2 0x8B53
|
||||
#define GL_INT_VEC3 0x8B54
|
||||
#define GL_INT_VEC4 0x8B55
|
||||
|
||||
#define GL_UNSIGNED_INT 0x1405
|
||||
#define GL_UNSIGNED_INT_VEC2 0x8DC6
|
||||
#define GL_UNSIGNED_INT_VEC3 0x8DC7
|
||||
#define GL_UNSIGNED_INT_VEC4 0x8DC8
|
||||
|
||||
#define GL_BOOL 0x8B56
|
||||
#define GL_BOOL_VEC2 0x8B57
|
||||
#define GL_BOOL_VEC3 0x8B58
|
||||
#define GL_BOOL_VEC4 0x8B59
|
||||
|
||||
#define GL_FLOAT_MAT2 0x8B5A
|
||||
#define GL_FLOAT_MAT3 0x8B5B
|
||||
#define GL_FLOAT_MAT4 0x8B5C
|
||||
#define GL_FLOAT_MAT2x3 0x8B65
|
||||
#define GL_FLOAT_MAT2x4 0x8B66
|
||||
#define GL_FLOAT_MAT3x2 0x8B67
|
||||
#define GL_FLOAT_MAT3x4 0x8B68
|
||||
#define GL_FLOAT_MAT4x2 0x8B69
|
||||
#define GL_FLOAT_MAT4x3 0x8B6A
|
||||
|
||||
#define GL_DOUBLE_MAT2 0x8F46
|
||||
#define GL_DOUBLE_MAT3 0x8F47
|
||||
#define GL_DOUBLE_MAT4 0x8F48
|
||||
#define GL_DOUBLE_MAT2x3 0x8F49
|
||||
#define GL_DOUBLE_MAT2x4 0x8F4A
|
||||
#define GL_DOUBLE_MAT3x2 0x8F4B
|
||||
#define GL_DOUBLE_MAT3x4 0x8F4C
|
||||
#define GL_DOUBLE_MAT4x2 0x8F4D
|
||||
#define GL_DOUBLE_MAT4x3 0x8F4E
|
||||
|
||||
#define GL_SAMPLER_1D 0x8B5D
|
||||
#define GL_SAMPLER_2D 0x8B5E
|
||||
#define GL_SAMPLER_3D 0x8B5F
|
||||
#define GL_SAMPLER_CUBE 0x8B60
|
||||
#define GL_SAMPLER_BUFFER 0x8DC2
|
||||
#define GL_SAMPLER_1D_ARRAY 0x8DC0
|
||||
#define GL_SAMPLER_2D_ARRAY 0x8DC1
|
||||
#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3
|
||||
#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
|
||||
#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
|
||||
#define GL_SAMPLER_1D_SHADOW 0x8B61
|
||||
#define GL_SAMPLER_2D_SHADOW 0x8B62
|
||||
#define GL_SAMPLER_2D_RECT 0x8B63
|
||||
#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64
|
||||
#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
|
||||
#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B
|
||||
#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C
|
||||
#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D
|
||||
#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C
|
||||
#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D
|
||||
|
||||
#define GL_INT_SAMPLER_1D 0x8DC9
|
||||
#define GL_INT_SAMPLER_2D 0x8DCA
|
||||
#define GL_INT_SAMPLER_3D 0x8DCB
|
||||
#define GL_INT_SAMPLER_CUBE 0x8DCC
|
||||
#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE
|
||||
#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
|
||||
#define GL_INT_SAMPLER_2D_RECT 0x8DCD
|
||||
#define GL_INT_SAMPLER_BUFFER 0x8DD0
|
||||
#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
|
||||
#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
|
||||
#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E
|
||||
#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E
|
||||
|
||||
#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1
|
||||
#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
|
||||
#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
|
||||
#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
|
||||
#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6
|
||||
#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
|
||||
#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5
|
||||
#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8
|
||||
#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
|
||||
#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F
|
||||
#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F
|
||||
#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
|
||||
|
||||
#define GL_IMAGE_1D 0x904C
|
||||
#define GL_IMAGE_2D 0x904D
|
||||
#define GL_IMAGE_3D 0x904E
|
||||
#define GL_IMAGE_2D_RECT 0x904F
|
||||
#define GL_IMAGE_CUBE 0x9050
|
||||
#define GL_IMAGE_BUFFER 0x9051
|
||||
#define GL_IMAGE_1D_ARRAY 0x9052
|
||||
#define GL_IMAGE_2D_ARRAY 0x9053
|
||||
#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054
|
||||
#define GL_IMAGE_2D_MULTISAMPLE 0x9055
|
||||
#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056
|
||||
#define GL_INT_IMAGE_1D 0x9057
|
||||
#define GL_INT_IMAGE_2D 0x9058
|
||||
#define GL_INT_IMAGE_3D 0x9059
|
||||
#define GL_INT_IMAGE_2D_RECT 0x905A
|
||||
#define GL_INT_IMAGE_CUBE 0x905B
|
||||
#define GL_INT_IMAGE_BUFFER 0x905C
|
||||
#define GL_INT_IMAGE_1D_ARRAY 0x905D
|
||||
#define GL_INT_IMAGE_2D_ARRAY 0x905E
|
||||
#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F
|
||||
#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060
|
||||
#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061
|
||||
#define GL_UNSIGNED_INT_IMAGE_1D 0x9062
|
||||
#define GL_UNSIGNED_INT_IMAGE_2D 0x9063
|
||||
#define GL_UNSIGNED_INT_IMAGE_3D 0x9064
|
||||
#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065
|
||||
#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066
|
||||
#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067
|
||||
#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068
|
||||
#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069
|
||||
#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A
|
||||
#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B
|
||||
#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C
|
||||
|
||||
#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB
|
@ -37,6 +37,8 @@
|
||||
#include "reflection.h"
|
||||
#include "localintermediate.h"
|
||||
|
||||
#include "gl_types.h"
|
||||
|
||||
//
|
||||
// Grow the reflection database through a friend traverser class of TReflection and a
|
||||
// collection of functions to do a liveness traversal that note what uniforms are used
|
||||
@ -93,7 +95,7 @@ public:
|
||||
if (reflection.nameToIndex.find(symbol.getName()) == reflection.nameToIndex.end()) {
|
||||
if (isReflectionGranularity(symbol.getType())) {
|
||||
reflection.nameToIndex[symbol.getName()] = reflection.indexToUniform.size();
|
||||
reflection.indexToUniform.push_back(TObjectReflection(symbol.getName(), -1, MapToGlType(symbol.getType()), MapToGlArraySize(symbol.getType()), -1));
|
||||
reflection.indexToUniform.push_back(TObjectReflection(symbol.getName(), -1, mapToGlType(symbol.getType()), mapToGlArraySize(symbol.getType()), -1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -265,7 +267,7 @@ public:
|
||||
if (name.size() > 0) {
|
||||
if (reflection.nameToIndex.find(name) == reflection.nameToIndex.end()) {
|
||||
reflection.nameToIndex[name] = reflection.indexToUniform.size();
|
||||
reflection.indexToUniform.push_back(TObjectReflection(name, offset, MapToGlType(node->getType()), MapToGlArraySize(node->getType()), blockIndex));
|
||||
reflection.indexToUniform.push_back(TObjectReflection(name, offset, mapToGlType(node->getType()), mapToGlArraySize(node->getType()), blockIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -306,15 +308,241 @@ public:
|
||||
return findBase(left);
|
||||
}
|
||||
|
||||
int MapToGlType(const TType& type)
|
||||
//
|
||||
// Translate a glslang sampler type into the GL API #define number.
|
||||
//
|
||||
int mapSamplerToGlType(TSampler sampler)
|
||||
{
|
||||
// TODO: reflection: flesh out all GL types
|
||||
#define GL_FLOAT_VEC4 0x8B52
|
||||
|
||||
return GL_FLOAT_VEC4;
|
||||
if (! sampler.image) {
|
||||
// a sampler...
|
||||
switch (sampler.type) {
|
||||
case EbtFloat:
|
||||
switch (sampler.dim) {
|
||||
case Esd1D:
|
||||
switch (sampler.shadow) {
|
||||
case false: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY : GL_SAMPLER_1D;
|
||||
case true: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY_SHADOW : GL_SAMPLER_1D_SHADOW;
|
||||
}
|
||||
case Esd2D:
|
||||
switch (sampler.ms) {
|
||||
case false:
|
||||
switch (sampler.shadow) {
|
||||
case false: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY : GL_SAMPLER_2D;
|
||||
case true: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY_SHADOW : GL_SAMPLER_2D_SHADOW;
|
||||
}
|
||||
case true: return sampler.arrayed ? GL_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_SAMPLER_2D_MULTISAMPLE;
|
||||
}
|
||||
case Esd3D:
|
||||
return GL_SAMPLER_3D;
|
||||
case EsdCube:
|
||||
switch (sampler.shadow) {
|
||||
case false: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY : GL_SAMPLER_CUBE;
|
||||
case true: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW : GL_SAMPLER_CUBE_SHADOW;
|
||||
}
|
||||
case EsdRect:
|
||||
return sampler.shadow ? GL_SAMPLER_2D_RECT_SHADOW : GL_SAMPLER_2D_RECT;
|
||||
case EsdBuffer:
|
||||
return GL_SAMPLER_BUFFER;
|
||||
}
|
||||
case EbtInt:
|
||||
switch (sampler.dim) {
|
||||
case Esd1D:
|
||||
return sampler.arrayed ? GL_INT_SAMPLER_1D_ARRAY : GL_INT_SAMPLER_1D;
|
||||
case Esd2D:
|
||||
switch (sampler.ms) {
|
||||
case false: return sampler.arrayed ? GL_INT_SAMPLER_2D_ARRAY : GL_INT_SAMPLER_2D;
|
||||
case true: return sampler.arrayed ? GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_INT_SAMPLER_2D_MULTISAMPLE;
|
||||
}
|
||||
case Esd3D:
|
||||
return GL_INT_SAMPLER_3D;
|
||||
case EsdCube:
|
||||
return sampler.arrayed ? GL_INT_SAMPLER_CUBE_MAP_ARRAY : GL_INT_SAMPLER_CUBE;
|
||||
case EsdRect:
|
||||
return GL_INT_SAMPLER_2D_RECT;
|
||||
case EsdBuffer:
|
||||
return GL_INT_SAMPLER_BUFFER;
|
||||
}
|
||||
case EbtUint:
|
||||
switch (sampler.dim) {
|
||||
case Esd1D:
|
||||
return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_1D_ARRAY : GL_UNSIGNED_INT_SAMPLER_1D;
|
||||
case Esd2D:
|
||||
switch (sampler.ms) {
|
||||
case false: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_ARRAY : GL_UNSIGNED_INT_SAMPLER_2D;
|
||||
case true: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE;
|
||||
}
|
||||
case Esd3D:
|
||||
return GL_UNSIGNED_INT_SAMPLER_3D;
|
||||
case EsdCube:
|
||||
return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY : GL_UNSIGNED_INT_SAMPLER_CUBE;
|
||||
case EsdRect:
|
||||
return GL_UNSIGNED_INT_SAMPLER_2D_RECT;
|
||||
case EsdBuffer:
|
||||
return GL_UNSIGNED_INT_SAMPLER_BUFFER;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
// an image...
|
||||
switch (sampler.type) {
|
||||
case EbtFloat:
|
||||
switch (sampler.dim) {
|
||||
case Esd1D:
|
||||
return sampler.arrayed ? GL_IMAGE_1D_ARRAY : GL_IMAGE_1D;
|
||||
case Esd2D:
|
||||
switch (sampler.ms) {
|
||||
case false: return sampler.arrayed ? GL_IMAGE_2D_ARRAY : GL_IMAGE_2D;
|
||||
case true: return sampler.arrayed ? GL_IMAGE_2D_MULTISAMPLE_ARRAY : GL_IMAGE_2D_MULTISAMPLE;
|
||||
}
|
||||
case Esd3D:
|
||||
return GL_IMAGE_3D;
|
||||
case EsdCube:
|
||||
return sampler.arrayed ? GL_IMAGE_CUBE_MAP_ARRAY : GL_IMAGE_CUBE;
|
||||
case EsdRect:
|
||||
return GL_IMAGE_2D_RECT;
|
||||
case EsdBuffer:
|
||||
return GL_IMAGE_BUFFER;
|
||||
}
|
||||
case EbtInt:
|
||||
switch (sampler.dim) {
|
||||
case Esd1D:
|
||||
return sampler.arrayed ? GL_INT_IMAGE_1D_ARRAY : GL_INT_IMAGE_1D;
|
||||
case Esd2D:
|
||||
switch (sampler.ms) {
|
||||
case false: return sampler.arrayed ? GL_INT_IMAGE_2D_ARRAY : GL_INT_IMAGE_2D;
|
||||
case true: return sampler.arrayed ? GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY : GL_INT_IMAGE_2D_MULTISAMPLE;
|
||||
}
|
||||
case Esd3D:
|
||||
return GL_INT_IMAGE_3D;
|
||||
case EsdCube:
|
||||
return sampler.arrayed ? GL_INT_IMAGE_CUBE_MAP_ARRAY : GL_INT_IMAGE_CUBE;
|
||||
case EsdRect:
|
||||
return GL_INT_IMAGE_2D_RECT;
|
||||
case EsdBuffer:
|
||||
return GL_INT_IMAGE_BUFFER;
|
||||
}
|
||||
case EbtUint:
|
||||
switch (sampler.dim) {
|
||||
case Esd1D:
|
||||
return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_1D_ARRAY : GL_UNSIGNED_INT_IMAGE_1D;
|
||||
case Esd2D:
|
||||
switch (sampler.ms) {
|
||||
case false: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_ARRAY : GL_UNSIGNED_INT_IMAGE_2D;
|
||||
case true: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY : GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE;
|
||||
}
|
||||
case Esd3D:
|
||||
return GL_UNSIGNED_INT_IMAGE_3D;
|
||||
case EsdCube:
|
||||
return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY : GL_UNSIGNED_INT_IMAGE_CUBE;
|
||||
case EsdRect:
|
||||
return GL_UNSIGNED_INT_IMAGE_2D_RECT;
|
||||
case EsdBuffer:
|
||||
return GL_UNSIGNED_INT_IMAGE_BUFFER;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int MapToGlArraySize(const TType& type)
|
||||
//
|
||||
// Translate a glslang type into the GL API #define number.
|
||||
// Ignores arrayness.
|
||||
//
|
||||
int mapToGlType(const TType& type)
|
||||
{
|
||||
switch (type.getBasicType()) {
|
||||
case EbtSampler:
|
||||
return mapSamplerToGlType(type.getSampler());
|
||||
case EbtStruct:
|
||||
case EbtBlock:
|
||||
case EbtVoid:
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (type.isVector()) {
|
||||
int offset = type.getVectorSize() - 2;
|
||||
switch (type.getBasicType()) {
|
||||
case EbtFloat: return GL_FLOAT_VEC2 + offset;
|
||||
case EbtDouble: return GL_DOUBLE_VEC2 + offset;
|
||||
case EbtInt: return GL_INT_VEC2 + offset;
|
||||
case EbtUint: return GL_UNSIGNED_INT_VEC2 + offset;
|
||||
case EbtBool: return GL_BOOL_VEC2 + offset;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
if (type.isMatrix()) {
|
||||
switch (type.getBasicType()) {
|
||||
case EbtFloat:
|
||||
switch (type.getMatrixCols()) {
|
||||
case 2:
|
||||
switch (type.getMatrixRows()) {
|
||||
case 2: return GL_FLOAT_MAT2;
|
||||
case 3: return GL_FLOAT_MAT2x3;
|
||||
case 4: return GL_FLOAT_MAT2x4;
|
||||
default: return 0;
|
||||
}
|
||||
case 3:
|
||||
switch (type.getMatrixRows()) {
|
||||
case 2: return GL_FLOAT_MAT3x2;
|
||||
case 3: return GL_FLOAT_MAT3;
|
||||
case 4: return GL_FLOAT_MAT3x4;
|
||||
default: return 0;
|
||||
}
|
||||
case 4:
|
||||
switch (type.getMatrixRows()) {
|
||||
case 2: return GL_FLOAT_MAT4x2;
|
||||
case 3: return GL_FLOAT_MAT4x3;
|
||||
case 4: return GL_FLOAT_MAT4;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
case EbtDouble:
|
||||
switch (type.getMatrixCols()) {
|
||||
case 2:
|
||||
switch (type.getMatrixRows()) {
|
||||
case 2: return GL_DOUBLE_MAT2;
|
||||
case 3: return GL_DOUBLE_MAT2x3;
|
||||
case 4: return GL_DOUBLE_MAT2x4;
|
||||
default: return 0;
|
||||
}
|
||||
case 3:
|
||||
switch (type.getMatrixRows()) {
|
||||
case 2: return GL_DOUBLE_MAT3x2;
|
||||
case 3: return GL_DOUBLE_MAT3;
|
||||
case 4: return GL_DOUBLE_MAT3x4;
|
||||
default: return 0;
|
||||
}
|
||||
case 4:
|
||||
switch (type.getMatrixRows()) {
|
||||
case 2: return GL_DOUBLE_MAT4x2;
|
||||
case 3: return GL_DOUBLE_MAT4x3;
|
||||
case 4: return GL_DOUBLE_MAT4;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (type.getVectorSize() == 1) {
|
||||
switch (type.getBasicType()) {
|
||||
case EbtFloat: return GL_FLOAT;
|
||||
case EbtDouble: return GL_DOUBLE;
|
||||
case EbtInt: return GL_INT;
|
||||
case EbtUint: return GL_UNSIGNED_INT;
|
||||
case EbtBool: return GL_BOOL;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapToGlArraySize(const TType& type)
|
||||
{
|
||||
return type.isArray() ? type.getArraySize() : 1;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class TObjectReflection {
|
||||
public:
|
||||
TObjectReflection(const TString& pName, int pOffset, int pGLDefineType, int pSize, int pIndex) :
|
||||
name(pName), offset(pOffset), glDefineType(pGLDefineType), size(pSize), index(pIndex) { }
|
||||
void dump() const { printf("%s: offset %d, type %d, arraySize %d, index %d\n", name.c_str(), offset, glDefineType, size, index); }
|
||||
void dump() const { printf("%s: offset %d, type %x, arraySize %d, index %d\n", name.c_str(), offset, glDefineType, size, index); }
|
||||
TString name;
|
||||
int offset;
|
||||
int glDefineType;
|
||||
|
Loading…
x
Reference in New Issue
Block a user