diff --git a/rendering_api/metal/src/core/devices/metal_output_device.cpp b/rendering_api/metal/src/core/devices/metal_output_device.cpp index 088044e..7fc1eff 100644 --- a/rendering_api/metal/src/core/devices/metal_output_device.cpp +++ b/rendering_api/metal/src/core/devices/metal_output_device.cpp @@ -20,41 +20,6 @@ // outputDevice->outputDevice->instance = const_cast(&instance); // { -// const char* shaderSrc = R"metal( -// #include -// using namespace metal; - -// struct VertexOut { -// float4 position [[position]]; -// float2 uv; -// }; - -// vertex VertexOut vs_main(uint vertexID [[vertex_id]]) { -// float2 positions[4] = { -// {-1.0, -1.0}, -// { 1.0, -1.0}, -// {-1.0, 1.0}, -// { 1.0, 1.0} -// }; -// float2 uvs[4] = { -// {0.0, 1.0}, -// {1.0, 1.0}, -// {0.0, 0.0}, -// {1.0, 0.0} -// }; - -// VertexOut out; -// out.position = float4(positions[vertexID], 0.0, 1.0); -// out.uv = uvs[vertexID]; -// return out; -// } - -// fragment float4 fs_main(VertexOut in [[stage_in]], -// texture2d colorTex [[texture(0)]], -// sampler samp [[sampler(0)]]) { -// return colorTex.sample(samp, in.uv); -// } -// )metal"; // NS::Error* error = nullptr; // MTL::CompileOptions* options = nullptr; diff --git a/rendering_api/metal/src/core/framebuffer.metal b/rendering_api/metal/src/core/framebuffer.metal new file mode 100644 index 0000000..dd75014 --- /dev/null +++ b/rendering_api/metal/src/core/framebuffer.metal @@ -0,0 +1,33 @@ +#include +using namespace metal; + +struct VertexOut { + float4 position [[position]]; + float2 uv; +}; + +vertex VertexOut vs_main(uint vertexID [[vertex_id]]) { + float2 positions[4] = { + {-1.0, -1.0}, + { 1.0, -1.0}, + {-1.0, 1.0}, + { 1.0, 1.0} + }; + float2 uvs[4] = { + {0.0, 1.0}, + {1.0, 1.0}, + {0.0, 0.0}, + {1.0, 0.0} + }; + + VertexOut out; + out.position = float4(positions[vertexID], 0.0, 1.0); + out.uv = uvs[vertexID]; + return out; +} + +fragment float4 fs_main(VertexOut in [[stage_in]], + texture2d colorTex [[texture(0)]], + sampler samp [[sampler(0)]]) { + return colorTex.sample(samp, in.uv); +} diff --git a/rendering_api/metal/src/core/triangle.metal b/rendering_api/metal/src/core/triangle.metal deleted file mode 100644 index cef8a88..0000000 --- a/rendering_api/metal/src/core/triangle.metal +++ /dev/null @@ -1,17 +0,0 @@ -#include -using namespace metal; - -vertex float4 -vertexShader(uint vertexID [[vertex_id]], - constant simd::float3* vertexPositions) -{ - float4 vertexOutPositions = float4(vertexPositions[vertexID][0], - vertexPositions[vertexID][1], - vertexPositions[vertexID][2], - 1.0f); - return vertexOutPositions; -} - -fragment float4 fragmentShader(float4 vertexOutPositions [[stage_in]]) { - return float4(182.0f/255.0f, 240.0f/255.0f, 228.0f/255.0f, 1.0f); -}