diff --git a/src/glsl/ir_print_glsl_visitor.cpp b/src/glsl/ir_print_glsl_visitor.cpp index 81a2c60be0b..6b1753ad453 100644 --- a/src/glsl/ir_print_glsl_visitor.cpp +++ b/src/glsl/ir_print_glsl_visitor.cpp @@ -50,7 +50,7 @@ static inline const char* get_precision_string (glsl_precision p) static const int tex_sampler_type_count = 7; // [glsl_sampler_dim] static const char* tex_sampler_dim_name[tex_sampler_type_count] = { - "1D", "2D", "3D", "Cube", "Rect", "Buf", "External", + "1D", "2D", "3D", "Cube", "Rect", "Buf", "2D", }; static int tex_sampler_dim_size[tex_sampler_type_count] = { 1, 2, 3, 3, 2, 2, 2, @@ -254,6 +254,8 @@ _mesa_print_ir_glsl(exec_list *instructions, str.asprintf_append ("#extension GL_EXT_shader_framebuffer_fetch : enable\n"); if (state->ARB_shader_bit_encoding_enable) str.asprintf_append("#extension GL_ARB_shader_bit_encoding : enable\n"); + if (state->OES_EGL_image_external_enable) + str.asprintf_append("#extension GL_OES_EGL_image_external : enable\n"); } // remove unused struct declarations diff --git a/src/glsl/ir_print_metal_visitor.cpp b/src/glsl/ir_print_metal_visitor.cpp index 0442208209b..781e8d3b6f8 100644 --- a/src/glsl/ir_print_metal_visitor.cpp +++ b/src/glsl/ir_print_metal_visitor.cpp @@ -99,6 +99,7 @@ struct metal_print_context , inoutStr(ralloc_strdup(buffer, "")) , uniformStr(ralloc_strdup(buffer, "")) , paramsStr(ralloc_strdup(buffer, "")) + , structsStr(ralloc_strdup(buffer, "")) , writingParams(false) , matrixCastsDone(false) , matrixConstructorsDone(false) @@ -117,6 +118,7 @@ struct metal_print_context string_buffer inoutStr; string_buffer uniformStr; string_buffer paramsStr; + string_buffer structsStr; bool writingParams; bool matrixCastsDone; bool matrixConstructorsDone; @@ -265,6 +267,10 @@ _mesa_print_ir_metal(exec_list *instructions, strOut = &ctx.inoutStr; } + else if (ir->ir_type == ir_type_typedecl) + { + strOut = &ctx.structsStr; + } ir_print_metal_visitor v (ctx, *strOut, >racker, mode, state); v.loopstate = ls; @@ -329,6 +335,7 @@ _mesa_print_ir_metal(exec_list *instructions, ctx.prefixStr.asprintf_append("%s", ctx.inputStr.c_str()); ctx.prefixStr.asprintf_append("%s", ctx.outputStr.c_str()); + ctx.prefixStr.asprintf_append("%s", ctx.structsStr.c_str()); ctx.prefixStr.asprintf_append("%s", ctx.uniformStr.c_str()); ctx.prefixStr.asprintf_append("%s", ctx.str.c_str()); diff --git a/tests/vertex/metal_struct_uniform-inES3.txt b/tests/vertex/metal_struct_uniform-inES3.txt new file mode 100644 index 00000000000..4e173b1d43b --- /dev/null +++ b/tests/vertex/metal_struct_uniform-inES3.txt @@ -0,0 +1,16 @@ +#version 300 es + +precision mediump float; + +struct MyStruct +{ + vec4 v1; + vec4 v2; +}; + +uniform MyStruct s1; + +void main() +{ + gl_Position = vec4(s1.v1.xyz, 1.0); +} diff --git a/tests/vertex/metal_struct_uniform-outES3.txt b/tests/vertex/metal_struct_uniform-outES3.txt new file mode 100644 index 00000000000..fe911b63c9b --- /dev/null +++ b/tests/vertex/metal_struct_uniform-outES3.txt @@ -0,0 +1,19 @@ +#version 300 es +precision mediump float; +struct MyStruct { + vec4 v1; + vec4 v2; +}; +uniform MyStruct s1; +void main () +{ + highp vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = s1.v1.xyz; + gl_Position = tmpvar_1; +} + + +// stats: 1 alu 0 tex 0 flow +// uniforms: 1 (total size: 0) +// #0: s1 (high other) 0x0 [-1] diff --git a/tests/vertex/metal_struct_uniform-outES3Metal.txt b/tests/vertex/metal_struct_uniform-outES3Metal.txt new file mode 100644 index 00000000000..ade89467f55 --- /dev/null +++ b/tests/vertex/metal_struct_uniform-outES3Metal.txt @@ -0,0 +1,29 @@ +#include +using namespace metal; +struct xlatMtlShaderInput { +}; +struct xlatMtlShaderOutput { + float4 gl_Position [[position]]; +}; +struct MyStruct { + float4 v1; + float4 v2; +}; +struct xlatMtlShaderUniform { + MyStruct s1; +}; +; +vertex xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]) +{ + xlatMtlShaderOutput _mtl_o; + float4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _mtl_u.s1.v1.xyz; + _mtl_o.gl_Position = tmpvar_1; + return _mtl_o; +} + + +// stats: 1 alu 0 tex 0 flow +// uniforms: 1 (total size: 0) +// #0: s1 (high other) 0x0 [-1] loc 0