2019-11-27 20:27:32 -08:00
|
|
|
//
|
|
|
|
// Shaders.metal
|
2020-07-13 10:23:33 -07:00
|
|
|
// Steve ][
|
2019-11-27 20:27:32 -08:00
|
|
|
//
|
|
|
|
// Created by Tamas Rudnai on 9/27/19.
|
2020-07-13 10:16:37 -07:00
|
|
|
// Copyright © 2019, 2020 Tamas Rudnai. All rights reserved.
|
2020-07-13 10:10:33 -07:00
|
|
|
//
|
|
|
|
// This file is part of Steve ][ -- The Apple ][ Emulator.
|
|
|
|
//
|
|
|
|
// Steve ][ is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Steve ][ is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Steve ][. If not, see <https://www.gnu.org/licenses/>.
|
2019-11-27 20:27:32 -08:00
|
|
|
//
|
|
|
|
|
|
|
|
#include <metal_stdlib>
|
|
|
|
using namespace metal;
|
|
|
|
|
|
|
|
|
2024-01-06 07:11:52 -08:00
|
|
|
// triangles
|
|
|
|
vertex float4 basic_vertex( // 1
|
2019-11-27 20:27:32 -08:00
|
|
|
const device packed_float3* vertex_array [[ buffer(0) ]], // 2
|
2024-01-06 07:11:52 -08:00
|
|
|
unsigned int vid [[ vertex_id ]] // 3
|
|
|
|
){
|
|
|
|
return float4(vertex_array[vid], 1.0); // 4
|
2019-11-27 20:27:32 -08:00
|
|
|
}
|
|
|
|
|
2024-01-06 07:11:52 -08:00
|
|
|
//struct Vertex {
|
|
|
|
// float4 position;
|
|
|
|
// float4 color;
|
|
|
|
//};
|
|
|
|
//
|
|
|
|
//struct VertexOut {
|
|
|
|
// float4 position [[position]];
|
|
|
|
// float4 color;
|
|
|
|
//};
|
|
|
|
//
|
|
|
|
//vertex VertexOut myVertexOut (
|
|
|
|
// const Vertex* vertexArray [[ buffer(0) ]],
|
|
|
|
// unsigned int vid [[ vertex_id ]]
|
|
|
|
//){
|
|
|
|
// VSO
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
// color of triangles
|
2019-11-27 20:27:32 -08:00
|
|
|
fragment half4 basic_fragment() { // 1
|
2024-01-06 07:11:52 -08:00
|
|
|
return half4( 255.0/255.0, 127.0/255.0, 255.0/255.0, 1.0); // half4(1.0); // 2
|
2019-11-27 20:27:32 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
kernel void add_arrays(device const float* inA,
|
|
|
|
device const float* inB,
|
|
|
|
device float* result,
|
|
|
|
uint index [[thread_position_in_grid]])
|
|
|
|
{
|
|
|
|
// the for-loop is replaced with a collection of threads, each of which
|
|
|
|
// calls this function.
|
|
|
|
result[index] = inA[index] + inB[index] + 1;
|
|
|
|
}
|
|
|
|
|
2024-01-06 07:11:52 -08:00
|
|
|
//vertex float4 basic_vertex( // 1
|
|
|
|
// const device packed_float3* vertex_array [[ buffer(0) ]], // 2
|
|
|
|
// unsigned int vid [[ vertex_id ]]) { // 3
|
|
|
|
// return float4(vertex_array[vid], 1.0); // 4
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//fragment half4 basic_fragment() { // 1
|
|
|
|
// return half4(1.0); // 2
|
|
|
|
//}
|
2019-11-27 20:27:32 -08:00
|
|
|
|