diff --git a/gfx/common/metal/MenuDisplay.m b/gfx/common/metal/MenuDisplay.m index 08b858364a..9296a1e31a 100644 --- a/gfx/common/metal/MenuDisplay.m +++ b/gfx/common/metal/MenuDisplay.m @@ -148,7 +148,7 @@ SpriteVertex *pv = (SpriteVertex *)range.data; for (unsigned i = 0; i < draw->coords->vertices; i++, pv++) { - pv->position = simd_make_float2(vertex[0], 1.0 - vertex[1]); + pv->position = simd_make_float2(vertex[0], 1.0f - vertex[1]); vertex += 2; pv->texCoord = simd_make_float2(tex_coord[0], tex_coord[1]); @@ -196,8 +196,9 @@ } [rce setRenderPipelineState:[_driver getStockShader:VIDEO_SHADER_STOCK_BLEND blend:_blend]]; + Uniforms uniforms = { - .projectionMatrix = draw->matrix_data ? *(matrix_float4x4 *)draw->matrix_data + .projectionMatrix = draw->matrix_data ? make_matrix_float4x4((const float *)draw->matrix_data) : _uniforms.projectionMatrix }; [rce setVertexBytes:&uniforms length:sizeof(uniforms) atIndex:BufferIndexUniforms]; diff --git a/gfx/common/metal/RendererCommon.h b/gfx/common/metal/RendererCommon.h index 49c3f74c66..320a9cc8b0 100644 --- a/gfx/common/metal/RendererCommon.h +++ b/gfx/common/metal/RendererCommon.h @@ -54,5 +54,6 @@ typedef NS_ENUM(NSUInteger, RTextureFilter) }; extern matrix_float4x4 matrix_proj_ortho(float left, float right, float top, float bottom); +extern matrix_float4x4 make_matrix_float4x4(const float *v); #endif /* RendererCommon_h */ diff --git a/gfx/common/metal/RendererCommon.m b/gfx/common/metal/RendererCommon.m index aca474a401..f3ed51db97 100644 --- a/gfx/common/metal/RendererCommon.m +++ b/gfx/common/metal/RendererCommon.m @@ -52,6 +52,17 @@ NSString *NSStringFromRPixelFormat(RPixelFormat format) return RPixelStrings[format]; } +matrix_float4x4 make_matrix_float4x4(const float *v) +{ + simd_float4 P = simd_make_float4(*v++, *v++, *v++, *v++); + simd_float4 Q = simd_make_float4(*v++, *v++, *v++, *v++); + simd_float4 R = simd_make_float4(*v++, *v++, *v++, *v++); + simd_float4 S = simd_make_float4(*v++, *v++, *v++, *v++); + + matrix_float4x4 mat = {P, Q, R, S}; + return mat; +} + matrix_float4x4 matrix_proj_ortho(float left, float right, float top, float bottom) { float near = 0; diff --git a/gfx/common/metal_common.m b/gfx/common/metal_common.m index a975c06f7f..b52fef8542 100644 --- a/gfx/common/metal_common.m +++ b/gfx/common/metal_common.m @@ -622,7 +622,7 @@ #pragma mark - FrameView -#define ALIGN(x) __attribute__((aligned(x))) +#define MTLALIGN(x) __attribute__((aligned(x))) typedef struct { @@ -638,7 +638,7 @@ typedef struct texture float4_t size_data; } texture_t; -typedef struct ALIGN(16) +typedef struct MTLALIGN(16) { matrix_float4x4 mvp;