mirror of
https://github.com/AxioDL/boo.git
synced 2025-12-09 13:37:48 +00:00
Initial integration of Metal API
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
|
||||
#if _WIN32
|
||||
#include <boo/graphicsdev/D3D.hpp>
|
||||
#elif __APPLE__
|
||||
#include <boo/graphicsdev/Metal.hpp>
|
||||
#endif
|
||||
|
||||
namespace boo
|
||||
@@ -336,6 +338,33 @@ struct TestApplicationCallback : IApplicationCallback
|
||||
pipeline = d3dF->newShaderPipeline(VS, PS, vsCompile, psCompile, vfmt,
|
||||
BlendFactorOne, BlendFactorZero, true, true, false);
|
||||
}
|
||||
#elif __APPLE__
|
||||
else if (factory->platform() == IGraphicsDataFactory::PlatformMetal)
|
||||
{
|
||||
MetalDataFactory* metalF = dynamic_cast<MetalDataFactory*>(factory);
|
||||
|
||||
static const char* VS =
|
||||
"struct VertData {float3 in_pos [[ attribute(0) ]]; float2 in_uv [[ attribute(1) ]];};\n"
|
||||
"struct VertToFrag {float4 out_pos [[ position ]]; float2 out_uv;};\n"
|
||||
"vertex VertToFrag main(VertData v [[ stage_in ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag retval;\n"
|
||||
" retval.out_pos = float4(v.in_pos, 1.0);\n"
|
||||
" retval.out_uv = v.in_uv;\n"
|
||||
" return retval;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"constexpr sampler samp(address::repeat);\n"
|
||||
"struct VertToFrag {float4 out_pos [[ position ]]; float2 out_uv;};\n"
|
||||
"fragment float4 main(VertToFrag d [[ stage_in ]], texture2d<float> tex [[ texture(0) ]])\n"
|
||||
"{\n"
|
||||
" return tex.sample(samp, d.out_uv);\n"
|
||||
"}\n";
|
||||
|
||||
pipeline = metalF->newShaderPipeline(VS, FS, vfmt, self->m_renderTarget,
|
||||
BlendFactorOne, BlendFactorZero, true, true, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user