Skip to content

Commit d304dab

Browse files
Add more missing external API, use buffer attachment 1 for uniforms
1 parent 30f9c6a commit d304dab

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

projects/xcode5/GLSLOptimiser/GLSLOptimizerBridge.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ typedef NS_ENUM(NSUInteger, GLSLOptPrecision) {
5959
@property SInt32 arraySize;
6060
@property UInt32 location;
6161

62+
-(UInt32)elementCount;
63+
-(UInt32)elementSize;
64+
-(UInt32)rawSize;
65+
6266
@end
6367

6468
@interface GLSLShader: NSObject

projects/xcode5/GLSLOptimiser/GLSLOptimizerBridge.mm

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,36 @@
1414

1515
@implementation GLSLShaderVariableDescription
1616

17+
-(UInt32)elementCount {
18+
return self.vecSize * self.matSize * (self.arraySize == -1 ? 1 : self.arraySize);
19+
}
20+
21+
-(UInt32)elementSize {
22+
UInt32 elementSize = 0;
23+
24+
switch (self.type) {
25+
case GLSLOptBasicTypeFloat:
26+
elementSize = sizeof(float);
27+
break;
28+
case GLSLOptBasicTypeInt:
29+
elementSize = sizeof(int);
30+
break;
31+
case GLSLOptBasicTypeBool:
32+
elementSize = sizeof(bool);
33+
break;
34+
case GLSLOptBasicTypeTex2D:
35+
case GLSLOptBasicTypeTex3D:
36+
case GLSLOptBasicTypeTexCube:
37+
break;
38+
default:
39+
break;
40+
}
41+
return elementSize;
42+
}
43+
-(UInt32)rawSize {
44+
return [self elementCount] * [self elementSize];
45+
}
46+
1747
@end
1848

1949
typedef NS_ENUM(NSUInteger, GLSLShaderVariableType) {

src/glsl/glsl_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ struct glsl_type {
427427
*/
428428
bool is_sampler() const
429429
{
430-
return base_type == GLSL_TYPE_SAMPLER;
430+
return base_type == GLSL_TYPE_SAMPLER;
431431
}
432432

433433
/**

src/glsl/ir_print_metal_visitor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ void ir_print_metal_visitor::visit(ir_function_signature *ir)
701701
buffer.asprintf_append ("fragment ");
702702
if (this->mode_whole == kPrintGlslVertex)
703703
buffer.asprintf_append ("vertex ");
704-
buffer.asprintf_append ("xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]");
704+
buffer.asprintf_append ("xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(1)]]");
705705
if (!ctx.paramsStr.empty())
706706
{
707707
buffer.asprintf_append ("%s", ctx.paramsStr.c_str());

0 commit comments

Comments
 (0)