mame/3rdparty/bgfx/examples/41-tess/matrices.sh
Julian Sikorski 0837e7451a WIP: sync bgfx, bx and bimg with latest upstream (#5723)
* Sync with bgfx upstream revision b91d0b6

* Sync with bx upstream revision d60912b

* Sync with bimg upstream revision bd81f60

* Add astc-codec decoder

* Rename VertexDecl to VertexLayout

* Rename UniformType enum Int1 to Sampler.

* Add NVN stub

* Fix unused-const-variable error on macOS

* Drop redundant explicit language parameters
buildoptions_cpp are only applied to c++ files and buildoptions_objcpp are only
applied to objective c++ files. As such, hardcoding -x offers no benefit while
preventing overrides (such as one needed by 3rdparty/bgfx/src/renderer_vk.cpp on
macOS) from working.

* Re-introduce -x c++ in places where C code is compiled as C++ to prevent clang from throwing a warning

* Build bgfx as Objective-C++ on macOS
It is needed due to included headers

* Enable Direct3D12 and Vulkan bgfx rendering backends

* Enable building of spirv shaders

* Properly escape /c in cmd call

* Comment out dx12 bgfx renderer

* Honor VERBOSE setting during shaders build

* Only invert hlsl shader XYZ_TO_sRGB matrix for opengl

* Add spirv shaders

* OpenGL ES needs transposed matrix too

* Metal needs transposed matrix as well
2019-10-13 07:50:38 -04:00

69 lines
1.5 KiB
Bash

//I decided to keep the non square matrices definition in the example, since I am still not sure how non square matrices should be treated in bgfx (Daniel Gavin)
#ifndef MATRICES_H_HEADER_GUARD
#define MATRICES_H_HEADER_GUARD
#ifndef __cplusplus
#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_SPIRV || BGFX_SHADER_LANGUAGE_METAL
# define mat3x4 float4x3
# define mat4x3 float3x4
#else
#endif // BGFX_SHADER_LANGUAGE_*
mat4x3 mtxFromRows(vec4 _0, vec4 _1, vec4 _2)
{
#if BGFX_SHADER_LANGUAGE_GLSL
return transpose(mat3x4(_0, _1, _2) );
#else
return mat4x3(_0, _1, _2);
#endif // BGFX_SHADER_LANGUAGE_GLSL
}
vec4 mtxGetRow(mat4x3 _0, uint row)
{
#if BGFX_SHADER_LANGUAGE_GLSL
return vec4(_0[0][row], _0[1][row], _0[2][row], _0[3][row]);
#else
return vec4(_0[row]);
#endif // BGFX_SHADER_LANGUAGE_GLSL
}
vec4 mtxGetRow(mat4 _0, uint row)
{
#if BGFX_SHADER_LANGUAGE_GLSL
return vec4(_0[0][row], _0[1][row], _0[2][row], _0[3][row]);
#else
return vec4(_0[row]);
#endif // BGFX_SHADER_LANGUAGE_GLSL
}
vec4 mtxGetColumn(mat4 _0, uint column)
{
#if BGFX_SHADER_LANGUAGE_GLSL
return vec4(_0[column]);
#else
return vec4(_0[0][column], _0[1][column], _0[2][column], _0[3][column]);
#endif // BGFX_SHADER_LANGUAGE_GLSL
}
float mtxGetElement(mat4 _0, uint column, uint row)
{
#if BGFX_SHADER_LANGUAGE_GLSL
return _0[column][row];
#else
return _0[row][column];
#endif // BGFX_SHADER_LANGUAGE_GLSL
}
#endif // __cplusplus
#endif // MATRICES_H_HEADER_GUARD