Force recompile if we add row-major transpose functions in MSL.
This commit is contained in:
parent
7b95168c3d
commit
d2df067dd4
@ -0,0 +1,35 @@
|
||||
cbuffer _104 : register(b0)
|
||||
{
|
||||
column_major float2x3 _104_var[3][4] : packoffset(c0);
|
||||
};
|
||||
|
||||
static float4 gl_Position;
|
||||
static float4 a_position;
|
||||
static float v_vtxResult;
|
||||
|
||||
struct SPIRV_Cross_Input
|
||||
{
|
||||
float4 a_position : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
{
|
||||
float v_vtxResult : TEXCOORD0;
|
||||
float4 gl_Position : SV_Position;
|
||||
};
|
||||
|
||||
void vert_main()
|
||||
{
|
||||
gl_Position = a_position;
|
||||
v_vtxResult = ((float(abs(_104_var[0][0][0].x - 2.0f) < 0.0500000007450580596923828125f) * float(abs(_104_var[0][0][0].y - 6.0f) < 0.0500000007450580596923828125f)) * float(abs(_104_var[0][0][0].z - (-6.0f)) < 0.0500000007450580596923828125f)) * ((float(abs(_104_var[0][0][1].x) < 0.0500000007450580596923828125f) * float(abs(_104_var[0][0][1].y - 5.0f) < 0.0500000007450580596923828125f)) * float(abs(_104_var[0][0][1].z - 5.0f) < 0.0500000007450580596923828125f));
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
a_position = stage_input.a_position;
|
||||
vert_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.gl_Position = gl_Position;
|
||||
stage_output.v_vtxResult = v_vtxResult;
|
||||
return stage_output;
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct Block
|
||||
{
|
||||
float2x3 var[3][4];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float4 a_position [[attribute(0)]];
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float v_vtxResult [[user(locn0)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization.
|
||||
float2x3 spvConvertFromRowMajor2x3(float2x3 m)
|
||||
{
|
||||
return float2x3(float3(m[0][0], m[0][2], m[1][1]), float3(m[0][1], m[1][0], m[1][2]));
|
||||
}
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]], constant Block& _104 [[buffer(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.gl_Position = in.a_position;
|
||||
out.v_vtxResult = ((float(abs(spvConvertFromRowMajor2x3(_104.var[0][0])[0].x - 2.0) < 0.0500000007450580596923828125) * float(abs(spvConvertFromRowMajor2x3(_104.var[0][0])[0].y - 6.0) < 0.0500000007450580596923828125)) * float(abs(spvConvertFromRowMajor2x3(_104.var[0][0])[0].z - (-6.0)) < 0.0500000007450580596923828125)) * ((float(abs(spvConvertFromRowMajor2x3(_104.var[0][0])[1].x) < 0.0500000007450580596923828125) * float(abs(spvConvertFromRowMajor2x3(_104.var[0][0])[1].y - 5.0) < 0.0500000007450580596923828125)) * float(abs(spvConvertFromRowMajor2x3(_104.var[0][0])[1].z - 5.0) < 0.0500000007450580596923828125));
|
||||
return out;
|
||||
}
|
||||
|
16
reference/opt/shaders/vert/read-from-row-major-array.vert
Normal file
16
reference/opt/shaders/vert/read-from-row-major-array.vert
Normal file
@ -0,0 +1,16 @@
|
||||
#version 310 es
|
||||
|
||||
layout(binding = 0, std140) uniform Block
|
||||
{
|
||||
layout(row_major) mat2x3 var[3][4];
|
||||
} _104;
|
||||
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 0) out mediump float v_vtxResult;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = a_position;
|
||||
v_vtxResult = ((float(abs(_104.var[0][0][0].x - 2.0) < 0.0500000007450580596923828125) * float(abs(_104.var[0][0][0].y - 6.0) < 0.0500000007450580596923828125)) * float(abs(_104.var[0][0][0].z - (-6.0)) < 0.0500000007450580596923828125)) * ((float(abs(_104.var[0][0][1].x) < 0.0500000007450580596923828125) * float(abs(_104.var[0][0][1].y - 5.0) < 0.0500000007450580596923828125)) * float(abs(_104.var[0][0][1].z - 5.0) < 0.0500000007450580596923828125));
|
||||
}
|
||||
|
64
reference/shaders-hlsl/vert/read-from-row-major-array.vert
Normal file
64
reference/shaders-hlsl/vert/read-from-row-major-array.vert
Normal file
@ -0,0 +1,64 @@
|
||||
cbuffer _104 : register(b0)
|
||||
{
|
||||
column_major float2x3 _104_var[3][4] : packoffset(c0);
|
||||
};
|
||||
|
||||
static float4 gl_Position;
|
||||
static float4 a_position;
|
||||
static float v_vtxResult;
|
||||
|
||||
struct SPIRV_Cross_Input
|
||||
{
|
||||
float4 a_position : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
{
|
||||
float v_vtxResult : TEXCOORD0;
|
||||
float4 gl_Position : SV_Position;
|
||||
};
|
||||
|
||||
float compare_float(float a, float b)
|
||||
{
|
||||
return float(abs(a - b) < 0.0500000007450580596923828125f);
|
||||
}
|
||||
|
||||
float compare_vec3(float3 a, float3 b)
|
||||
{
|
||||
float param = a.x;
|
||||
float param_1 = b.x;
|
||||
float param_2 = a.y;
|
||||
float param_3 = b.y;
|
||||
float param_4 = a.z;
|
||||
float param_5 = b.z;
|
||||
return (compare_float(param, param_1) * compare_float(param_2, param_3)) * compare_float(param_4, param_5);
|
||||
}
|
||||
|
||||
float compare_mat2x3(float2x3 a, float2x3 b)
|
||||
{
|
||||
float3 param = a[0];
|
||||
float3 param_1 = b[0];
|
||||
float3 param_2 = a[1];
|
||||
float3 param_3 = b[1];
|
||||
return compare_vec3(param, param_1) * compare_vec3(param_2, param_3);
|
||||
}
|
||||
|
||||
void vert_main()
|
||||
{
|
||||
gl_Position = a_position;
|
||||
float result = 1.0f;
|
||||
float2x3 param = _104_var[0][0];
|
||||
float2x3 param_1 = float2x3(float3(2.0f, 6.0f, -6.0f), float3(0.0f, 5.0f, 5.0f));
|
||||
result *= compare_mat2x3(param, param_1);
|
||||
v_vtxResult = result;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
a_position = stage_input.a_position;
|
||||
vert_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.gl_Position = gl_Position;
|
||||
stage_output.v_vtxResult = v_vtxResult;
|
||||
return stage_output;
|
||||
}
|
66
reference/shaders-msl/vert/read-from-row-major-array.vert
Normal file
66
reference/shaders-msl/vert/read-from-row-major-array.vert
Normal file
@ -0,0 +1,66 @@
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct Block
|
||||
{
|
||||
float2x3 var[3][4];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float4 a_position [[attribute(0)]];
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float v_vtxResult [[user(locn0)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
// Implementation of a conversion of matrix content from RowMajor to ColumnMajor organization.
|
||||
float2x3 spvConvertFromRowMajor2x3(float2x3 m)
|
||||
{
|
||||
return float2x3(float3(m[0][0], m[0][2], m[1][1]), float3(m[0][1], m[1][0], m[1][2]));
|
||||
}
|
||||
|
||||
float compare_float(thread const float& a, thread const float& b)
|
||||
{
|
||||
return float(abs(a - b) < 0.0500000007450580596923828125);
|
||||
}
|
||||
|
||||
float compare_vec3(thread const float3& a, thread const float3& b)
|
||||
{
|
||||
float param = a.x;
|
||||
float param_1 = b.x;
|
||||
float param_2 = a.y;
|
||||
float param_3 = b.y;
|
||||
float param_4 = a.z;
|
||||
float param_5 = b.z;
|
||||
return (compare_float(param, param_1) * compare_float(param_2, param_3)) * compare_float(param_4, param_5);
|
||||
}
|
||||
|
||||
float compare_mat2x3(thread const float2x3& a, thread const float2x3& b)
|
||||
{
|
||||
float3 param = a[0];
|
||||
float3 param_1 = b[0];
|
||||
float3 param_2 = a[1];
|
||||
float3 param_3 = b[1];
|
||||
return compare_vec3(param, param_1) * compare_vec3(param_2, param_3);
|
||||
}
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]], constant Block& _104 [[buffer(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.gl_Position = in.a_position;
|
||||
float result = 1.0;
|
||||
float2x3 param = spvConvertFromRowMajor2x3(_104.var[0][0]);
|
||||
float2x3 param_1 = float2x3(float3(2.0, 6.0, -6.0), float3(0.0, 5.0, 5.0));
|
||||
result *= compare_mat2x3(param, param_1);
|
||||
out.v_vtxResult = result;
|
||||
return out;
|
||||
}
|
||||
|
45
reference/shaders/vert/read-from-row-major-array.vert
Normal file
45
reference/shaders/vert/read-from-row-major-array.vert
Normal file
@ -0,0 +1,45 @@
|
||||
#version 310 es
|
||||
|
||||
layout(binding = 0, std140) uniform Block
|
||||
{
|
||||
layout(row_major) mat2x3 var[3][4];
|
||||
} _104;
|
||||
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 0) out mediump float v_vtxResult;
|
||||
|
||||
mediump float compare_float(float a, float b)
|
||||
{
|
||||
return float(abs(a - b) < 0.0500000007450580596923828125);
|
||||
}
|
||||
|
||||
mediump float compare_vec3(vec3 a, vec3 b)
|
||||
{
|
||||
float param = a.x;
|
||||
float param_1 = b.x;
|
||||
float param_2 = a.y;
|
||||
float param_3 = b.y;
|
||||
float param_4 = a.z;
|
||||
float param_5 = b.z;
|
||||
return (compare_float(param, param_1) * compare_float(param_2, param_3)) * compare_float(param_4, param_5);
|
||||
}
|
||||
|
||||
mediump float compare_mat2x3(mat2x3 a, mat2x3 b)
|
||||
{
|
||||
vec3 param = a[0];
|
||||
vec3 param_1 = b[0];
|
||||
vec3 param_2 = a[1];
|
||||
vec3 param_3 = b[1];
|
||||
return compare_vec3(param, param_1) * compare_vec3(param_2, param_3);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = a_position;
|
||||
mediump float result = 1.0;
|
||||
mat2x3 param = _104.var[0][0];
|
||||
mat2x3 param_1 = mat2x3(vec3(2.0, 6.0, -6.0), vec3(0.0, 5.0, 5.0));
|
||||
result *= compare_mat2x3(param, param_1);
|
||||
v_vtxResult = result;
|
||||
}
|
||||
|
20
shaders-hlsl/vert/read-from-row-major-array.vert
Normal file
20
shaders-hlsl/vert/read-from-row-major-array.vert
Normal file
@ -0,0 +1,20 @@
|
||||
#version 310 es
|
||||
layout(location = 0) in highp vec4 a_position;
|
||||
layout(location = 0) out mediump float v_vtxResult;
|
||||
|
||||
layout(set = 0, binding = 0, std140, row_major) uniform Block
|
||||
{
|
||||
highp mat2x3 var[3][4];
|
||||
};
|
||||
|
||||
mediump float compare_float (highp float a, highp float b) { return abs(a - b) < 0.05 ? 1.0 : 0.0; }
|
||||
mediump float compare_vec3 (highp vec3 a, highp vec3 b) { return compare_float(a.x, b.x)*compare_float(a.y, b.y)*compare_float(a.z, b.z); }
|
||||
mediump float compare_mat2x3 (highp mat2x3 a, highp mat2x3 b){ return compare_vec3(a[0], b[0])*compare_vec3(a[1], b[1]); }
|
||||
|
||||
void main (void)
|
||||
{
|
||||
gl_Position = a_position;
|
||||
mediump float result = 1.0;
|
||||
result *= compare_mat2x3(var[0][0], mat2x3(2.0, 6.0, -6.0, 0.0, 5.0, 5.0));
|
||||
v_vtxResult = result;
|
||||
}
|
20
shaders-msl/vert/read-from-row-major-array.vert
Normal file
20
shaders-msl/vert/read-from-row-major-array.vert
Normal file
@ -0,0 +1,20 @@
|
||||
#version 310 es
|
||||
layout(location = 0) in highp vec4 a_position;
|
||||
layout(location = 0) out mediump float v_vtxResult;
|
||||
|
||||
layout(set = 0, binding = 0, std140, row_major) uniform Block
|
||||
{
|
||||
highp mat2x3 var[3][4];
|
||||
};
|
||||
|
||||
mediump float compare_float (highp float a, highp float b) { return abs(a - b) < 0.05 ? 1.0 : 0.0; }
|
||||
mediump float compare_vec3 (highp vec3 a, highp vec3 b) { return compare_float(a.x, b.x)*compare_float(a.y, b.y)*compare_float(a.z, b.z); }
|
||||
mediump float compare_mat2x3 (highp mat2x3 a, highp mat2x3 b){ return compare_vec3(a[0], b[0])*compare_vec3(a[1], b[1]); }
|
||||
|
||||
void main (void)
|
||||
{
|
||||
gl_Position = a_position;
|
||||
mediump float result = 1.0;
|
||||
result *= compare_mat2x3(var[0][0], mat2x3(2.0, 6.0, -6.0, 0.0, 5.0, 5.0));
|
||||
v_vtxResult = result;
|
||||
}
|
20
shaders/vert/read-from-row-major-array.vert
Normal file
20
shaders/vert/read-from-row-major-array.vert
Normal file
@ -0,0 +1,20 @@
|
||||
#version 310 es
|
||||
layout(location = 0) in highp vec4 a_position;
|
||||
layout(location = 0) out mediump float v_vtxResult;
|
||||
|
||||
layout(set = 0, binding = 0, std140, row_major) uniform Block
|
||||
{
|
||||
highp mat2x3 var[3][4];
|
||||
};
|
||||
|
||||
mediump float compare_float (highp float a, highp float b) { return abs(a - b) < 0.05 ? 1.0 : 0.0; }
|
||||
mediump float compare_vec3 (highp vec3 a, highp vec3 b) { return compare_float(a.x, b.x)*compare_float(a.y, b.y)*compare_float(a.z, b.z); }
|
||||
mediump float compare_mat2x3 (highp mat2x3 a, highp mat2x3 b){ return compare_vec3(a[0], b[0])*compare_vec3(a[1], b[1]); }
|
||||
|
||||
void main (void)
|
||||
{
|
||||
gl_Position = a_position;
|
||||
mediump float result = 1.0;
|
||||
result *= compare_mat2x3(var[0][0], mat2x3(2.0, 6.0, -6.0, 0.0, 5.0, 5.0));
|
||||
v_vtxResult = result;
|
||||
}
|
@ -2801,7 +2801,7 @@ bool CompilerMSL::member_is_non_native_row_major_matrix(const SPIRType &type, ui
|
||||
return false;
|
||||
|
||||
// Non-matrix or column-major matrix types do not need to be converted.
|
||||
if (!has_member_decoration(type.self, index, DecorationRowMajor))
|
||||
if (!combined_decoration_for_member(type, index).get(DecorationRowMajor))
|
||||
return false;
|
||||
|
||||
// Generate a function that will swap matrix elements from row-major to column-major.
|
||||
@ -2838,7 +2838,10 @@ void CompilerMSL::add_convert_row_major_matrix_function(uint32_t cols, uint32_t
|
||||
|
||||
auto rslt = spv_function_implementations.insert(spv_func);
|
||||
if (rslt.second)
|
||||
{
|
||||
add_pragma_line("#pragma clang diagnostic ignored \"-Wmissing-prototypes\"");
|
||||
force_recompile = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Wraps the expression string in a function call that converts the
|
||||
|
Loading…
Reference in New Issue
Block a user