Skip to content

Commit

Permalink
Add more missing external API, use buffer attachment 1 for uniforms
Browse files Browse the repository at this point in the history
  • Loading branch information
tokyovigilante committed Jun 14, 2015
1 parent d57d39f commit fb9171b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
4 changes: 4 additions & 0 deletions projects/xcode5/GLSLOptimiser/GLSLOptimizerBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ typedef NS_ENUM(NSUInteger, GLSLOptPrecision) {
@property SInt32 arraySize;
@property UInt32 location;

-(UInt32)elementCount;
-(UInt32)elementSize;
-(UInt32)rawSize;

@end

@interface GLSLShader: NSObject
Expand Down
30 changes: 30 additions & 0 deletions projects/xcode5/GLSLOptimiser/GLSLOptimizerBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,36 @@

@implementation GLSLShaderVariableDescription

-(UInt32)elementCount {
return self.vecSize * self.matSize * (self.arraySize == -1 ? 1 : self.arraySize);
}

-(UInt32)elementSize {
UInt32 elementSize = 0;

switch (self.type) {
case GLSLOptBasicTypeFloat:
elementSize = sizeof(float);
break;
case GLSLOptBasicTypeInt:
elementSize = sizeof(int);
break;
case GLSLOptBasicTypeBool:
elementSize = sizeof(bool);
break;
case GLSLOptBasicTypeTex2D:
case GLSLOptBasicTypeTex3D:
case GLSLOptBasicTypeTexCube:
break;
default:
break;
}
return elementSize;
}
-(UInt32)rawSize {
return [self elementCount] * [self elementSize];
}

@end

typedef NS_ENUM(NSUInteger, GLSLShaderVariableType) {
Expand Down
2 changes: 1 addition & 1 deletion src/glsl/glsl_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ struct glsl_type {
*/
bool is_sampler() const
{
return base_type == GLSL_TYPE_SAMPLER;
return base_type == GLSL_TYPE_SAMPLER;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/glsl/ir_print_metal_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ void ir_print_metal_visitor::visit(ir_function_signature *ir)
buffer.asprintf_append ("fragment ");
if (this->mode_whole == kPrintGlslVertex)
buffer.asprintf_append ("vertex ");
buffer.asprintf_append ("xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]");
buffer.asprintf_append ("xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(1)]]");
if (!ctx.paramsStr.empty())
{
buffer.asprintf_append ("%s", ctx.paramsStr.c_str());
Expand Down

0 comments on commit fb9171b

Please sign in to comment.